Merged in bugfix/integrationstests (pull request #7)
Add get, list, create, deprecate query service integration tests * showtestlines * more config * roundone * splituptests * splitfurther
This commit is contained in:
@@ -42,7 +42,7 @@ func (s *Service) submitCreate(ctx context.Context, entity *queryprocessor.Creat
|
||||
if err != nil {
|
||||
return uuid.Nil, err
|
||||
}
|
||||
// defer tx.Rollback(ctx)
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
qtx := s.db.Queries.WithTx(tx)
|
||||
|
||||
|
||||
@@ -28,7 +28,10 @@ func (s *Service) Get(ctx context.Context, id uuid.UUID) (*Query, error) {
|
||||
}
|
||||
|
||||
func ParseFullActiveQuery(q *repository.Fullactivequery) (*Query, error) {
|
||||
reqQueryIDs := database.MustToUUIDArray(q.Requiredids)
|
||||
reqQueryIDs := []uuid.UUID{}
|
||||
if !(len(q.Requiredids) == 0 || len(q.Requiredids) == 1 && database.MustToUUID(q.Requiredids[0]) == uuid.Nil) {
|
||||
reqQueryIDs = database.MustToUUIDArray(q.Requiredids)
|
||||
}
|
||||
|
||||
qType, err := queryprocessor.ParseDBType(q.Type)
|
||||
if err != nil {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
"github.com/pashagolub/pgxmock/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -51,3 +52,47 @@ func TestGet(t *testing.T) {
|
||||
|
||||
assert.EqualExportedValues(t, query, *returnQuery)
|
||||
}
|
||||
|
||||
func TestFullActiveQueryEmpty(t *testing.T) {
|
||||
dbQuery := &repository.Fullactivequery{
|
||||
ID: database.MustToDBUUID(uuid.New()),
|
||||
Type: repository.QuerytypeContextFull,
|
||||
Activeversion: int32(1),
|
||||
Latestversion: int32(2),
|
||||
Config: []byte(""),
|
||||
Requiredids: []pgtype.UUID{},
|
||||
}
|
||||
|
||||
out, err := query.ParseFullActiveQuery(dbQuery)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualExportedValues(t, query.Query{
|
||||
ID: database.MustToUUID(dbQuery.ID),
|
||||
Type: queryprocessor.TypeContextFull,
|
||||
ActiveVersion: int32(1),
|
||||
LatestVersion: int32(2),
|
||||
Config: "",
|
||||
RequiredQueryIDs: []uuid.UUID{},
|
||||
}, *out)
|
||||
}
|
||||
|
||||
func TestFullActiveQueryWithNullUUID(t *testing.T) {
|
||||
dbQuery := &repository.Fullactivequery{
|
||||
ID: database.MustToDBUUID(uuid.New()),
|
||||
Type: repository.QuerytypeContextFull,
|
||||
Activeversion: int32(1),
|
||||
Latestversion: int32(2),
|
||||
Config: []byte(""),
|
||||
Requiredids: []pgtype.UUID{database.MustToDBUUID(uuid.Nil)},
|
||||
}
|
||||
|
||||
out, err := query.ParseFullActiveQuery(dbQuery)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualExportedValues(t, query.Query{
|
||||
ID: database.MustToUUID(dbQuery.ID),
|
||||
Type: queryprocessor.TypeContextFull,
|
||||
ActiveVersion: int32(1),
|
||||
LatestVersion: int32(2),
|
||||
Config: "",
|
||||
RequiredQueryIDs: []uuid.UUID{},
|
||||
}, *out)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user