2025-01-13 15:02:43 +00:00
|
|
|
package integration_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"queryorchestration/internal/test"
|
2025-01-15 19:45:51 +00:00
|
|
|
queryservice "queryorchestration/pkg/queryService"
|
2025-01-13 15:02:43 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestQueryService(t *testing.T) {
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
|
2025-01-15 19:45:51 +00:00
|
|
|
address, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
2025-01-13 15:02:43 +00:00
|
|
|
defer cleanup()
|
|
|
|
|
|
2025-01-15 19:45:51 +00:00
|
|
|
client, err := queryservice.NewClientWithResponses(address)
|
|
|
|
|
assert.Nil(t, err)
|
2025-01-13 15:02:43 +00:00
|
|
|
|
2025-01-15 19:45:51 +00:00
|
|
|
idRes, err := client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{
|
|
|
|
|
Type: queryservice.CONTEXTFULL,
|
2025-01-13 15:02:43 +00:00
|
|
|
})
|
|
|
|
|
assert.Nil(t, err)
|
2025-01-15 19:45:51 +00:00
|
|
|
assert.NotNil(t, idRes)
|
|
|
|
|
assert.NotNil(t, idRes.JSON201)
|
|
|
|
|
id := idRes.JSON201.Id
|
2025-01-13 15:02:43 +00:00
|
|
|
assert.NotEmpty(t, id)
|
|
|
|
|
|
2025-01-15 19:45:51 +00:00
|
|
|
queryRes, err := client.GetQueryByIdWithResponse(ctx, id)
|
2025-01-13 15:02:43 +00:00
|
|
|
assert.Nil(t, err)
|
2025-01-15 19:45:51 +00:00
|
|
|
assert.Equal(t, id, queryRes.JSON200.Id)
|
|
|
|
|
assert.Equal(t, queryservice.CONTEXTFULL, queryRes.JSON200.Type)
|
|
|
|
|
assert.Equal(t, int32(1), queryRes.JSON200.ActiveVersion)
|
|
|
|
|
assert.Equal(t, int32(1), queryRes.JSON200.LatestVersion)
|
|
|
|
|
assert.Nil(t, queryRes.JSON200.Config)
|
|
|
|
|
assert.Nil(t, queryRes.JSON200.RequiredQueries)
|
|
|
|
|
|
|
|
|
|
queriesRes, err := client.ListQueriesWithResponse(ctx)
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
assert.Len(t, queriesRes.JSON200.Queries, 1)
|
|
|
|
|
assert.Equal(t, id, queriesRes.JSON200.Queries[0].Id)
|
|
|
|
|
|
|
|
|
|
res, err := client.UpdateQueryWithResponse(ctx, id, queryservice.QueryUpdate{
|
2025-01-13 15:02:43 +00:00
|
|
|
Config: nil,
|
|
|
|
|
ActiveVersion: nil,
|
2025-01-15 19:45:51 +00:00
|
|
|
RequiredQueries: &[]string{},
|
2025-01-13 15:02:43 +00:00
|
|
|
})
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
assert.NotNil(t, res)
|
|
|
|
|
|
2025-01-15 19:45:51 +00:00
|
|
|
queryRes, err = client.GetQueryByIdWithResponse(ctx, id)
|
2025-01-13 15:02:43 +00:00
|
|
|
assert.Nil(t, err)
|
2025-01-15 19:45:51 +00:00
|
|
|
assert.Equal(t, id, queryRes.JSON200.Id)
|
|
|
|
|
assert.Equal(t, queryservice.CONTEXTFULL, queryRes.JSON200.Type)
|
|
|
|
|
assert.Equal(t, int32(1), queryRes.JSON200.ActiveVersion)
|
|
|
|
|
assert.Equal(t, int32(1), queryRes.JSON200.LatestVersion)
|
|
|
|
|
assert.Nil(t, queryRes.JSON200.Config)
|
|
|
|
|
assert.Nil(t, queryRes.JSON200.RequiredQueries)
|
2025-01-13 15:02:43 +00:00
|
|
|
}
|