Merged in feature/client (pull request #31)
Client Entity * repolevel * servicefunctions * openapiclientget * openapiupdate * client * vendor
This commit is contained in:
@@ -176,10 +176,8 @@ func TestNormalizeCreate(t *testing.T) {
|
||||
}
|
||||
svc := New(db)
|
||||
|
||||
cfg := "{}"
|
||||
create := &queryprocessor.Create{
|
||||
Type: queryprocessor.TypeJsonExtractor,
|
||||
Config: &cfg,
|
||||
RequiredQueryIDs: &[]uuid.UUID{},
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
"queryorchestration/internal/database"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func (s *Service) Deprecate(ctx context.Context, id uuid.UUID) error {
|
||||
dbId := database.MustToDBUUID(id)
|
||||
|
||||
exists, err := s.db.Queries.IsQueryDeprecated(ctx, dbId)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if exists {
|
||||
return nil
|
||||
}
|
||||
|
||||
err = s.db.Queries.DeprecateQuery(ctx, dbId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package query_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"queryorchestration/internal/database"
|
||||
"queryorchestration/internal/database/repository"
|
||||
"queryorchestration/internal/query"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/pashagolub/pgxmock/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDeprecate(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
pool, err := pgxmock.NewPool()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open pgxmock database: %v", err)
|
||||
}
|
||||
queries := repository.New(pool)
|
||||
db := &database.Connection{
|
||||
Queries: queries,
|
||||
Pool: pool,
|
||||
}
|
||||
svc := query.New(db)
|
||||
|
||||
id := uuid.New()
|
||||
|
||||
pool.ExpectQuery("name: IsQueryDeprecated :one").WithArgs(database.MustToDBUUID(id)).WillReturnRows(
|
||||
pgxmock.NewRows([]string{"exists"}).
|
||||
AddRow(false),
|
||||
)
|
||||
pool.ExpectExec("name: DeprecateQuery :exec").WithArgs(database.MustToDBUUID(id)).
|
||||
WillReturnResult(pgxmock.NewResult("", 1))
|
||||
|
||||
err = svc.Deprecate(ctx, id)
|
||||
assert.Nil(t, err)
|
||||
|
||||
pool.ExpectQuery("name: IsQueryDeprecated :one").WithArgs(database.MustToDBUUID(id)).WillReturnRows(
|
||||
pgxmock.NewRows([]string{"exists"}).
|
||||
AddRow(true),
|
||||
)
|
||||
|
||||
err = svc.Deprecate(ctx, id)
|
||||
assert.Nil(t, err)
|
||||
|
||||
pool.ExpectQuery("name: IsQueryDeprecated :one").WithArgs(database.MustToDBUUID(id)).WillReturnRows(
|
||||
pgxmock.NewRows([]string{"exists"}),
|
||||
)
|
||||
|
||||
err = svc.Deprecate(ctx, id)
|
||||
assert.NotNil(t, err)
|
||||
|
||||
pool.ExpectQuery("name: IsQueryDeprecated :one").WithArgs(database.MustToDBUUID(id)).WillReturnRows(
|
||||
pgxmock.NewRows([]string{"exists"}).
|
||||
AddRow(false),
|
||||
)
|
||||
pool.ExpectExec("name: DeprecateQuery :exec").WithArgs(database.MustToDBUUID(id)).
|
||||
WillReturnError(errors.New("unable to deprecate query"))
|
||||
|
||||
err = svc.Deprecate(ctx, id)
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
@@ -45,11 +45,7 @@ func (s *Service) normalizeConfig(config Config) error {
|
||||
|
||||
strJSON := string(prettyJSON)
|
||||
|
||||
if strJSON == "{}" {
|
||||
config.SetConfig(nil)
|
||||
} else {
|
||||
config.SetConfig(&strJSON)
|
||||
}
|
||||
config.SetConfig(&strJSON)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func TestNormalizeConfig(t *testing.T) {
|
||||
entity.Config = &cfg
|
||||
err = s.normalizeConfig(&entity)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, entity.Config)
|
||||
assert.Equal(t, "{}", *(entity.Config))
|
||||
|
||||
cfg = "{\"hello\":\"bye\"}"
|
||||
entity.Config = &cfg
|
||||
|
||||
@@ -297,7 +297,7 @@ func TestNormalizeUpdate(t *testing.T) {
|
||||
assert.EqualExportedValues(t, queryprocessor.Update{
|
||||
ID: current.ID,
|
||||
ActiveVersion: &aV,
|
||||
Config: nil,
|
||||
Config: &cfg,
|
||||
RequiredQueryIDs: nil,
|
||||
}, *update)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user