57764272c3
Feature/unittests * addedmoretests * easyquerytests * fixotelinit * preppedqueriestotestcontainer * dbqueries * splitintoqueryfiles * covered the bases
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
package query_test
|
|
|
|
import (
|
|
"queryorchestration/internal/database"
|
|
"queryorchestration/internal/database/repository"
|
|
"queryorchestration/internal/query"
|
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestParseQuery(t *testing.T) {
|
|
q := &query.Query{
|
|
ID: uuid.New(),
|
|
Type: queryprocessor.TypeJsonExtractor,
|
|
ActiveVersion: int32(1),
|
|
LatestVersion: int32(2),
|
|
RequiredQueryIDs: []uuid.UUID{
|
|
uuid.New(),
|
|
},
|
|
Config: "example",
|
|
}
|
|
|
|
out := query.ParseQuery(q)
|
|
assert.EqualExportedValues(t, queryprocessor.Query{
|
|
ID: q.ID,
|
|
Type: q.Type,
|
|
Version: q.ActiveVersion,
|
|
RequiredQueryIDs: q.RequiredQueryIDs,
|
|
Config: q.Config,
|
|
}, *out)
|
|
}
|
|
|
|
func TestParseFullActiveQuery(t *testing.T) {
|
|
q := &repository.Fullactivequery{
|
|
ID: database.MustToDBUUID(uuid.New()),
|
|
Type: repository.QuerytypeContextFull,
|
|
Activeversion: int32(1),
|
|
Latestversion: int32(2),
|
|
Requiredids: []pgtype.UUID{
|
|
database.MustToDBUUID(uuid.New()),
|
|
},
|
|
Config: []byte("example"),
|
|
}
|
|
|
|
out, err := query.ParseFullActiveQuery(q)
|
|
assert.Nil(t, err)
|
|
assert.EqualExportedValues(t, query.Query{
|
|
ID: database.MustToUUID(q.ID),
|
|
Type: queryprocessor.TypeContextFull,
|
|
ActiveVersion: q.Activeversion,
|
|
LatestVersion: q.Latestversion,
|
|
RequiredQueryIDs: []uuid.UUID{
|
|
database.MustToUUID(q.Requiredids[0]),
|
|
},
|
|
Config: string(q.Config),
|
|
}, *out)
|
|
}
|