Merged in feature/testquery (pull request #39)
Test Query * depstextandclean * startedcleaningresult * resulttidyup * roundone * cleaning * unsyncedquery * startedtestsandsimplification * api * querytests * resultprocessortests * unittests * cleanup
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"queryorchestration/internal/database"
|
||||
"queryorchestration/internal/database/repository"
|
||||
"queryorchestration/internal/query"
|
||||
queryprocessor "queryorchestration/internal/query/processor"
|
||||
resultprocessor "queryorchestration/internal/query/result/processor"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -16,7 +16,7 @@ func TestParseQuery(t *testing.T) {
|
||||
cfg := "example"
|
||||
q := &query.Query{
|
||||
ID: uuid.New(),
|
||||
Type: queryprocessor.TypeJsonExtractor,
|
||||
Type: resultprocessor.TypeJsonExtractor,
|
||||
ActiveVersion: int32(1),
|
||||
LatestVersion: int32(2),
|
||||
RequiredQueryIDs: &[]uuid.UUID{
|
||||
@@ -26,7 +26,7 @@ func TestParseQuery(t *testing.T) {
|
||||
}
|
||||
|
||||
out := query.ParseQuery(q)
|
||||
assert.EqualExportedValues(t, queryprocessor.Query{
|
||||
assert.EqualExportedValues(t, resultprocessor.Query{
|
||||
ID: q.ID,
|
||||
Type: q.Type,
|
||||
Version: q.ActiveVersion,
|
||||
@@ -52,7 +52,7 @@ func TestParseFullActiveQuery(t *testing.T) {
|
||||
bcfg := string(q.Config)
|
||||
assert.EqualExportedValues(t, query.Query{
|
||||
ID: database.MustToUUID(q.ID),
|
||||
Type: queryprocessor.TypeContextFull,
|
||||
Type: resultprocessor.TypeContextFull,
|
||||
ActiveVersion: q.Activeversion,
|
||||
LatestVersion: q.Latestversion,
|
||||
RequiredQueryIDs: &[]uuid.UUID{
|
||||
@@ -61,3 +61,61 @@ func TestParseFullActiveQuery(t *testing.T) {
|
||||
Config: &bcfg,
|
||||
}, *out)
|
||||
}
|
||||
|
||||
func TestFullActiveQueryEmpty(t *testing.T) {
|
||||
dbQuery := &repository.Fullactivequery{
|
||||
ID: database.MustToDBUUID(uuid.New()),
|
||||
Type: repository.QuerytypeContextFull,
|
||||
Activeversion: int32(1),
|
||||
Latestversion: int32(2),
|
||||
}
|
||||
|
||||
out, err := query.ParseFullActiveQuery(dbQuery)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualExportedValues(t, query.Query{
|
||||
ID: database.MustToUUID(dbQuery.ID),
|
||||
Type: resultprocessor.TypeContextFull,
|
||||
ActiveVersion: int32(1),
|
||||
LatestVersion: int32(2),
|
||||
}, *out)
|
||||
}
|
||||
|
||||
func TestFullActiveQueryWithNullUUID(t *testing.T) {
|
||||
dbQuery := &repository.Fullactivequery{
|
||||
ID: database.MustToDBUUID(uuid.New()),
|
||||
Type: repository.QuerytypeContextFull,
|
||||
Activeversion: int32(1),
|
||||
Latestversion: int32(2),
|
||||
}
|
||||
|
||||
out, err := query.ParseFullActiveQuery(dbQuery)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualExportedValues(t, query.Query{
|
||||
ID: database.MustToUUID(dbQuery.ID),
|
||||
Type: resultprocessor.TypeContextFull,
|
||||
ActiveVersion: int32(1),
|
||||
LatestVersion: int32(2),
|
||||
}, *out)
|
||||
}
|
||||
|
||||
func TestFullActiveQueryArray(t *testing.T) {
|
||||
dbQueries := []*repository.Fullactivequery{
|
||||
{
|
||||
ID: database.MustToDBUUID(uuid.New()),
|
||||
Type: repository.QuerytypeContextFull,
|
||||
Activeversion: int32(1),
|
||||
Latestversion: int32(2),
|
||||
},
|
||||
}
|
||||
|
||||
out, err := query.ParseFullActiveQueryArray(dbQueries)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualExportedValues(t, []*query.Query{
|
||||
{
|
||||
ID: database.MustToUUID(dbQueries[0].ID),
|
||||
Type: resultprocessor.TypeContextFull,
|
||||
ActiveVersion: int32(1),
|
||||
LatestVersion: int32(2),
|
||||
},
|
||||
}, out)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user