Merged in feature/demo (pull request #122)
Demo+Tests * fixbasedemo * fix * splitrepotest * reg * go
This commit is contained in:
@@ -29,6 +29,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- aws-server-network
|
||||
|
||||
@@ -60,6 +65,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- aws-server-network
|
||||
|
||||
@@ -91,6 +101,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- aws-server-network
|
||||
|
||||
@@ -122,6 +137,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- aws-server-network
|
||||
|
||||
@@ -158,6 +178,11 @@ services:
|
||||
AWS_ENDPOINT_URL_S3: "http://localstack:4566"
|
||||
AWS_ENDPOINT_URL_SQS: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- aws-server-network
|
||||
|
||||
@@ -189,6 +214,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- aws-server-network
|
||||
|
||||
@@ -220,6 +250,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- aws-server-network
|
||||
|
||||
@@ -251,6 +286,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- aws-server-network
|
||||
|
||||
@@ -282,6 +322,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- aws-server-network
|
||||
|
||||
@@ -313,6 +358,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- aws-server-network
|
||||
|
||||
|
||||
@@ -29,6 +29,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- server-network
|
||||
|
||||
@@ -60,6 +65,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- server-network
|
||||
|
||||
@@ -91,6 +101,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- server-network
|
||||
|
||||
@@ -122,6 +137,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- server-network
|
||||
|
||||
@@ -153,6 +173,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- server-network
|
||||
|
||||
@@ -184,6 +209,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- server-network
|
||||
|
||||
@@ -215,6 +245,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- server-network
|
||||
|
||||
@@ -246,6 +281,15 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
# COGNITO_USER_POOL_ID: ${COGNITO_USER_POOL_ID}
|
||||
# COGNITO_CLIENT_SECRET: ${COGNITO_CLIENT_SECRET}
|
||||
# COGNITO_DOMAIN: ${COGNITO_DOMAIN}
|
||||
# COGNITO_CLIENT_ID: ${COGNITO_CLIENT_ID}
|
||||
networks:
|
||||
- server-network
|
||||
|
||||
@@ -277,6 +321,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- server-network
|
||||
|
||||
@@ -308,6 +357,11 @@ services:
|
||||
DB_NOSSL: ${DB_NOSSL}
|
||||
AWS_ENDPOINT_URL: "http://localstack:4566"
|
||||
AWS_S3_USE_PATH_STYLE: true
|
||||
DISABLE_AUTH: true
|
||||
COGNITO_USER_POOL_ID: "fillin"
|
||||
COGNITO_CLIENT_SECRET: "fillin"
|
||||
COGNITO_DOMAIN: "fillin"
|
||||
COGNITO_CLIENT_ID: "fillin"
|
||||
networks:
|
||||
- server-network
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ func TestClientSync(t *testing.T) {
|
||||
}, docExternal)
|
||||
})
|
||||
|
||||
t.Run("valid extraction", func(t *testing.T) {
|
||||
t.Run("standard extraction", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -349,7 +349,6 @@ func TestClientSync(t *testing.T) {
|
||||
Fields: []byte(`{"first_key": null}`),
|
||||
}, docExternal)
|
||||
|
||||
t.Run("document standard results", func(t *testing.T) {
|
||||
contextResultId, err := queries.AddResult(ctx, &repository.AddResultParams{
|
||||
Queryid: contextQueryID,
|
||||
Value: "example_context",
|
||||
@@ -410,6 +409,20 @@ func TestClientSync(t *testing.T) {
|
||||
}, docExternal)
|
||||
})
|
||||
|
||||
t.Run("update upstream query", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
cfg := &serviceconfig.BaseConfig{}
|
||||
net := test.DepNetwork.Get(t, ctx)
|
||||
_ = test.CreateDB(t, ctx, cfg, net, &test.CreateDatabaseConfig{})
|
||||
|
||||
queries := cfg.GetDBQueries()
|
||||
|
||||
contextQueryID, jsonQueryID := createDependentQueries(t, ctx, queries)
|
||||
clientId := createClientWithCollector(t, ctx, queries)
|
||||
documentID, _, textId := createDocumentWithCollectorAndResults(t, ctx, queries, clientId, contextQueryID, jsonQueryID)
|
||||
|
||||
contextLatestVersion, err := queries.AddLatestQueryVersion(ctx, contextQueryID)
|
||||
require.NoError(t, err)
|
||||
err = queries.AddActiveQueryVersion(ctx, &repository.AddActiveQueryVersionParams{
|
||||
@@ -418,10 +431,10 @@ func TestClientSync(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
isSynced, err = queries.IsClientSynced(ctx, &clientId)
|
||||
isSynced, err := queries.IsClientSynced(ctx, &clientId)
|
||||
require.NoError(t, err)
|
||||
assert.False(t, isSynced)
|
||||
docExternal, err = queries.GetDocumentExternal(ctx, documentID)
|
||||
docExternal, err := queries.GetDocumentExternal(ctx, documentID)
|
||||
require.NoError(t, err)
|
||||
assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{
|
||||
ID: documentID,
|
||||
@@ -430,7 +443,6 @@ func TestClientSync(t *testing.T) {
|
||||
Fields: []byte(`{"first_key": null}`),
|
||||
}, docExternal)
|
||||
|
||||
t.Run("update upstream query", func(t *testing.T) {
|
||||
contextResultId, err := queries.AddResult(ctx, &repository.AddResultParams{
|
||||
Queryid: contextQueryID,
|
||||
Value: "context_version_2",
|
||||
@@ -490,7 +502,20 @@ func TestClientSync(t *testing.T) {
|
||||
}, docExternal)
|
||||
})
|
||||
|
||||
t.Run("update text entry", func(t *testing.T) {
|
||||
t.Run("update text extry", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
cfg := &serviceconfig.BaseConfig{}
|
||||
net := test.DepNetwork.Get(t, ctx)
|
||||
_ = test.CreateDB(t, ctx, cfg, net, &test.CreateDatabaseConfig{})
|
||||
|
||||
queries := cfg.GetDBQueries()
|
||||
|
||||
contextQueryID, jsonQueryID := createDependentQueries(t, ctx, queries)
|
||||
clientId := createClientWithCollector(t, ctx, queries)
|
||||
documentID, cleanId, _ := createDocumentWithCollectorAndResults(t, ctx, queries, clientId, contextQueryID, jsonQueryID)
|
||||
|
||||
textId, err := queries.AddDocumentText(ctx, &repository.AddDocumentTextParams{
|
||||
Bucket: "hi",
|
||||
Key: "hello",
|
||||
@@ -508,10 +533,10 @@ func TestClientSync(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
isSynced, err = queries.IsClientSynced(ctx, &clientId)
|
||||
isSynced, err := queries.IsClientSynced(ctx, &clientId)
|
||||
require.NoError(t, err)
|
||||
assert.False(t, isSynced)
|
||||
docExternal, err = queries.GetDocumentExternal(ctx, documentID)
|
||||
docExternal, err := queries.GetDocumentExternal(ctx, documentID)
|
||||
require.NoError(t, err)
|
||||
assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{
|
||||
ID: documentID,
|
||||
@@ -524,7 +549,7 @@ func TestClientSync(t *testing.T) {
|
||||
Queryid: contextQueryID,
|
||||
Value: "updated_text_context",
|
||||
Textentryid: textId,
|
||||
Queryversion: 2,
|
||||
Queryversion: 1,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -578,7 +603,24 @@ func TestClientSync(t *testing.T) {
|
||||
Fields: []byte(`{"first_key": "updated_text_json"}`),
|
||||
}, docExternal)
|
||||
})
|
||||
t.Run("updated clean entry", func(t *testing.T) {
|
||||
|
||||
t.Run("update clean entry", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
cfg := &serviceconfig.BaseConfig{}
|
||||
net := test.DepNetwork.Get(t, ctx)
|
||||
_ = test.CreateDB(t, ctx, cfg, net, &test.CreateDatabaseConfig{})
|
||||
|
||||
queries := cfg.GetDBQueries()
|
||||
|
||||
contextQueryID, jsonQueryID := createDependentQueries(t, ctx, queries)
|
||||
clientId := createClientWithCollector(t, ctx, queries)
|
||||
documentID, _, _ := createDocumentWithCollectorAndResults(t, ctx, queries, clientId, contextQueryID, jsonQueryID)
|
||||
|
||||
bucket := "cu"
|
||||
key := "kk"
|
||||
hash := "hash"
|
||||
cleanthreeid, err := queries.AddDocumentClean(ctx, &repository.AddDocumentCleanParams{
|
||||
Documentid: documentID,
|
||||
Bucket: &bucket,
|
||||
@@ -596,10 +638,10 @@ func TestClientSync(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
isSynced, err = queries.IsClientSynced(ctx, &clientId)
|
||||
isSynced, err := queries.IsClientSynced(ctx, &clientId)
|
||||
require.NoError(t, err)
|
||||
assert.False(t, isSynced)
|
||||
docExternal, err = queries.GetDocumentExternal(ctx, documentID)
|
||||
docExternal, err := queries.GetDocumentExternal(ctx, documentID)
|
||||
require.NoError(t, err)
|
||||
assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{
|
||||
ID: documentID,
|
||||
@@ -641,7 +683,7 @@ func TestClientSync(t *testing.T) {
|
||||
Queryid: contextQueryID,
|
||||
Value: "update_clean_context",
|
||||
Textentryid: textThreeId,
|
||||
Queryversion: contextLatestVersion,
|
||||
Queryversion: 1,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -694,23 +736,37 @@ func TestClientSync(t *testing.T) {
|
||||
Hash: "example_hash",
|
||||
Fields: []byte(`{"first_key": "update_clean_json"}`),
|
||||
}, docExternal)
|
||||
})
|
||||
|
||||
t.Run("change collector name", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
cfg := &serviceconfig.BaseConfig{}
|
||||
net := test.DepNetwork.Get(t, ctx)
|
||||
_ = test.CreateDB(t, ctx, cfg, net, &test.CreateDatabaseConfig{})
|
||||
|
||||
queries := cfg.GetDBQueries()
|
||||
|
||||
contextQueryID, jsonQueryID := createDependentQueries(t, ctx, queries)
|
||||
clientId := createClientWithCollector(t, ctx, queries)
|
||||
documentID, _, _ := createDocumentWithCollectorAndResults(t, ctx, queries, clientId, contextQueryID, jsonQueryID)
|
||||
|
||||
latestCollectorVersion, err := queries.AddLatestCollectorVersion(ctx, clientId)
|
||||
require.NoError(t, err)
|
||||
|
||||
isSynced, err = queries.IsClientSynced(ctx, &clientId)
|
||||
isSynced, err := queries.IsClientSynced(ctx, &clientId)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, isSynced)
|
||||
docExternal, err = queries.GetDocumentExternal(ctx, documentID)
|
||||
docExternal, err := queries.GetDocumentExternal(ctx, documentID)
|
||||
require.NoError(t, err)
|
||||
assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{
|
||||
ID: documentID,
|
||||
Clientid: clientId,
|
||||
Hash: "example_hash",
|
||||
Fields: []byte(`{"first_key": "update_clean_json"}`),
|
||||
Fields: []byte(`{"first_key": "json_value"}`),
|
||||
}, docExternal)
|
||||
|
||||
t.Run("update collector name", func(t *testing.T) {
|
||||
err = queries.SetActiveCollectorVersion(ctx, &repository.SetActiveCollectorVersionParams{
|
||||
Versionid: latestCollectorVersion,
|
||||
Clientid: clientId,
|
||||
@@ -726,7 +782,7 @@ func TestClientSync(t *testing.T) {
|
||||
ID: documentID,
|
||||
Clientid: clientId,
|
||||
Hash: "example_hash",
|
||||
Fields: []byte(`{"first_key": "update_clean_json"}`),
|
||||
Fields: []byte(`{"first_key": "json_value"}`),
|
||||
}, docExternal)
|
||||
|
||||
err = queries.RemoveCollectorQuery(ctx, &repository.RemoveCollectorQueryParams{
|
||||
@@ -765,33 +821,59 @@ func TestClientSync(t *testing.T) {
|
||||
ID: documentID,
|
||||
Clientid: clientId,
|
||||
Hash: "example_hash",
|
||||
Fields: []byte(`{"second_key": "update_clean_json"}`),
|
||||
Fields: []byte(`{"second_key": "json_value"}`),
|
||||
}, docExternal)
|
||||
})
|
||||
|
||||
t.Run("add existing query", func(t *testing.T) {
|
||||
err = queries.AddCollectorQuery(ctx, &repository.AddCollectorQueryParams{
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
cfg := &serviceconfig.BaseConfig{}
|
||||
net := test.DepNetwork.Get(t, ctx)
|
||||
_ = test.CreateDB(t, ctx, cfg, net, &test.CreateDatabaseConfig{})
|
||||
|
||||
queries := cfg.GetDBQueries()
|
||||
|
||||
contextQueryID, jsonQueryID := createDependentQueries(t, ctx, queries)
|
||||
clientId := createClientWithCollector(t, ctx, queries)
|
||||
documentID, _, _ := createDocumentWithCollectorAndResults(t, ctx, queries, clientId, contextQueryID, jsonQueryID)
|
||||
|
||||
err := queries.AddCollectorQuery(ctx, &repository.AddCollectorQueryParams{
|
||||
Clientid: clientId,
|
||||
Queryid: contextQueryID,
|
||||
Addedversion: latestCollectorVersion,
|
||||
Addedversion: 1,
|
||||
Name: "example_key",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
isSynced, err = queries.IsClientSynced(ctx, &clientId)
|
||||
isSynced, err := queries.IsClientSynced(ctx, &clientId)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, isSynced)
|
||||
docExternal, err = queries.GetDocumentExternal(ctx, documentID)
|
||||
docExternal, err := queries.GetDocumentExternal(ctx, documentID)
|
||||
require.NoError(t, err)
|
||||
assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{
|
||||
ID: documentID,
|
||||
Clientid: clientId,
|
||||
Hash: "example_hash",
|
||||
Fields: []byte(`{"second_key": "update_clean_json", "example_key": "update_clean_context"}`),
|
||||
Fields: []byte(`{"first_key": "json_value", "example_key": "example_context"}`),
|
||||
}, docExternal)
|
||||
})
|
||||
|
||||
t.Run("add super query", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
cfg := &serviceconfig.BaseConfig{}
|
||||
net := test.DepNetwork.Get(t, ctx)
|
||||
_ = test.CreateDB(t, ctx, cfg, net, &test.CreateDatabaseConfig{})
|
||||
|
||||
queries := cfg.GetDBQueries()
|
||||
|
||||
contextQueryID, jsonQueryID := createDependentQueries(t, ctx, queries)
|
||||
clientId := createClientWithCollector(t, ctx, queries)
|
||||
documentID, _, textId := createDocumentWithCollectorAndResults(t, ctx, queries, clientId, contextQueryID, jsonQueryID)
|
||||
|
||||
superQueryID, err := queries.CreateQuery(ctx, repository.Querytype(repository.QuerytypeJsonExtractor))
|
||||
require.NoError(t, err)
|
||||
superQueryVersion, err := queries.AddLatestQueryVersion(ctx, superQueryID)
|
||||
@@ -811,47 +893,27 @@ func TestClientSync(t *testing.T) {
|
||||
superResultId, err := queries.AddResult(ctx, &repository.AddResultParams{
|
||||
Queryid: superQueryID,
|
||||
Value: "super_value",
|
||||
Textentryid: textThreeId,
|
||||
Textentryid: textId,
|
||||
Queryversion: superQueryVersion,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
isSynced, err = queries.IsClientSynced(ctx, &clientId)
|
||||
isSynced, err := queries.IsClientSynced(ctx, &clientId)
|
||||
require.NoError(t, err)
|
||||
assert.False(t, isSynced)
|
||||
docExternal, err = queries.GetDocumentExternal(ctx, documentID)
|
||||
docExternal, err := queries.GetDocumentExternal(ctx, documentID)
|
||||
require.NoError(t, err)
|
||||
assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{
|
||||
ID: documentID,
|
||||
Clientid: clientId,
|
||||
Hash: "example_hash",
|
||||
Fields: []byte(`{"second_key": null, "example_key": null}`),
|
||||
Fields: []byte(`{"first_key": null}`),
|
||||
}, docExternal)
|
||||
|
||||
contextResultId, err := queries.AddResult(ctx, &repository.AddResultParams{
|
||||
Queryid: contextQueryID,
|
||||
Value: "context_with_super_value",
|
||||
Textentryid: textThreeId,
|
||||
Queryversion: contextLatestVersion,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
isSynced, err = queries.IsClientSynced(ctx, &clientId)
|
||||
require.NoError(t, err)
|
||||
assert.False(t, isSynced)
|
||||
docExternal, err = queries.GetDocumentExternal(ctx, documentID)
|
||||
require.NoError(t, err)
|
||||
assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{
|
||||
ID: documentID,
|
||||
Clientid: clientId,
|
||||
Hash: "example_hash",
|
||||
Fields: []byte(`{"second_key": null, "example_key": null}`),
|
||||
}, docExternal)
|
||||
|
||||
jsonResultId, err := queries.AddResult(ctx, &repository.AddResultParams{
|
||||
Queryid: jsonQueryID,
|
||||
Value: "json_with_super",
|
||||
Textentryid: textThreeId,
|
||||
Textentryid: textId,
|
||||
Queryversion: 1,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -865,7 +927,27 @@ func TestClientSync(t *testing.T) {
|
||||
ID: documentID,
|
||||
Clientid: clientId,
|
||||
Hash: "example_hash",
|
||||
Fields: []byte(`{"second_key": null, "example_key": null}`),
|
||||
Fields: []byte(`{"first_key": null}`),
|
||||
}, docExternal)
|
||||
|
||||
jsonResultId, err := queries.AddResult(ctx, &repository.AddResultParams{
|
||||
Queryid: jsonQueryID,
|
||||
Value: "json_with_super",
|
||||
Textentryid: textId,
|
||||
Queryversion: 1,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
isSynced, err = queries.IsClientSynced(ctx, &clientId)
|
||||
require.NoError(t, err)
|
||||
assert.False(t, isSynced)
|
||||
docExternal, err = queries.GetDocumentExternal(ctx, documentID)
|
||||
require.NoError(t, err)
|
||||
assert.EqualExportedValues(t, &repository.GetDocumentExternalRow{
|
||||
ID: documentID,
|
||||
Clientid: clientId,
|
||||
Hash: "example_hash",
|
||||
Fields: []byte(`{"first_key": null}`),
|
||||
}, docExternal)
|
||||
|
||||
err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{
|
||||
@@ -883,7 +965,7 @@ func TestClientSync(t *testing.T) {
|
||||
ID: documentID,
|
||||
Clientid: clientId,
|
||||
Hash: "example_hash",
|
||||
Fields: []byte(`{"second_key": null, "example_key": "context_with_super_value"}`),
|
||||
Fields: []byte(`{"first_key": null}`),
|
||||
}, docExternal)
|
||||
|
||||
err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{
|
||||
@@ -901,9 +983,85 @@ func TestClientSync(t *testing.T) {
|
||||
ID: documentID,
|
||||
Clientid: clientId,
|
||||
Hash: "example_hash",
|
||||
Fields: []byte(`{"second_key": "json_with_super", "example_key": "context_with_super_value"}`),
|
||||
Fields: []byte(`{"first_key": "json_with_super"}`),
|
||||
}, docExternal)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func createDocumentWithCollectorAndResults(t testing.TB, ctx context.Context, queries *repository.Queries, clientId string, contextQueryID, jsonQueryID uuid.UUID) (uuid.UUID, uuid.UUID, uuid.UUID) {
|
||||
err := queries.AddCollectorQuery(ctx, &repository.AddCollectorQueryParams{
|
||||
Clientid: clientId,
|
||||
Queryid: jsonQueryID,
|
||||
Addedversion: 1,
|
||||
Name: "first_key",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
bucket := "example_bucket"
|
||||
|
||||
documentID, err := queries.CreateDocument(ctx, &repository.CreateDocumentParams{
|
||||
Clientid: clientId,
|
||||
Hash: "example_hash",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
key := "example_key"
|
||||
hash := "hahssh"
|
||||
cleanId, err := queries.AddDocumentClean(ctx, &repository.AddDocumentCleanParams{
|
||||
Documentid: documentID,
|
||||
Bucket: &bucket,
|
||||
Key: &key,
|
||||
Hash: &hash,
|
||||
Mimetype: repository.NullCleanmimetype{
|
||||
Valid: true,
|
||||
Cleanmimetype: repository.CleanmimetypeApplicationPdf,
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
err = queries.AddDocumentCleanEntry(ctx, &repository.AddDocumentCleanEntryParams{
|
||||
Cleanid: cleanId,
|
||||
Version: 1,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
textId, err := queries.AddDocumentText(ctx, &repository.AddDocumentTextParams{
|
||||
Cleanid: cleanId,
|
||||
Part: 0,
|
||||
Createdat: pgtype.Timestamp{
|
||||
Time: time.Now().UTC(),
|
||||
Valid: true,
|
||||
},
|
||||
Bucket: "hi",
|
||||
Key: "hello",
|
||||
Hash: "example",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
err = queries.AddDocumentTextEntry(ctx, &repository.AddDocumentTextEntryParams{
|
||||
Version: 1,
|
||||
Textid: textId,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
contextResultId, err := queries.AddResult(ctx, &repository.AddResultParams{
|
||||
Queryid: contextQueryID,
|
||||
Value: "example_context",
|
||||
Textentryid: textId,
|
||||
Queryversion: 1,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
jsonResultId, err := queries.AddResult(ctx, &repository.AddResultParams{
|
||||
Queryid: jsonQueryID,
|
||||
Value: "json_value",
|
||||
Textentryid: textId,
|
||||
Queryversion: 1,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
err = queries.AddResultDependency(ctx, &repository.AddResultDependencyParams{
|
||||
Resultid: jsonResultId,
|
||||
Requiredresultid: contextResultId,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
return documentID, cleanId, textId
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user