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:
@@ -0,0 +1,23 @@
|
||||
package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
||||
"queryorchestration/internal/test"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestExportService(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
conn, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
defer cleanup()
|
||||
|
||||
expClient := serviceinterfaces.NewExportServiceClient(conn)
|
||||
|
||||
idRes, err := expClient.Trigger(ctx, &serviceinterfaces.ExportTrigger{})
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, idRes)
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
||||
"queryorchestration/internal/test"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestJobCollectorService(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
conn, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
defer cleanup()
|
||||
|
||||
collClient := serviceinterfaces.NewJobCollectorServiceClient(conn)
|
||||
|
||||
idRes, err := collClient.Create(ctx, &serviceinterfaces.JobCollectorCreate{})
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, idRes)
|
||||
|
||||
collRes, err := collClient.Get(ctx, &serviceinterfaces.IdMessage{})
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, collRes)
|
||||
|
||||
res, err := collClient.Update(ctx, &serviceinterfaces.JobCollectorUpdate{})
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, res)
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
||||
"queryorchestration/internal/test"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestQueryServiceList(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
conn, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
defer cleanup()
|
||||
|
||||
client := serviceinterfaces.NewQueryServiceClient(conn)
|
||||
|
||||
idRes, err := client.Create(ctx, &serviceinterfaces.QueryCreate{
|
||||
Type: serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL,
|
||||
Config: nil,
|
||||
RequiredQueries: []string{},
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
id := idRes.GetId()
|
||||
assert.NotEmpty(t, id)
|
||||
|
||||
queriesRes, err := client.List(ctx, &serviceinterfaces.QueryFilter{})
|
||||
assert.Nil(t, err)
|
||||
assert.Len(t, queriesRes.Queries, 1)
|
||||
assert.Equal(t, id, queriesRes.Queries[0].Id)
|
||||
|
||||
res, err := client.Update(ctx, &serviceinterfaces.QueryUpdate{
|
||||
Id: id,
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, res)
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
||||
"queryorchestration/internal/test"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestQueryService(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
conn, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
defer cleanup()
|
||||
|
||||
client := serviceinterfaces.NewQueryServiceClient(conn)
|
||||
|
||||
idRes, err := client.Create(ctx, &serviceinterfaces.QueryCreate{
|
||||
Type: serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL,
|
||||
Config: nil,
|
||||
RequiredQueries: []string{},
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
id := idRes.GetId()
|
||||
assert.NotEmpty(t, id)
|
||||
|
||||
queryRes, err := client.Get(ctx, &serviceinterfaces.IdMessage{
|
||||
Id: id,
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, id, queryRes.Id)
|
||||
assert.Equal(t, serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL, queryRes.Type)
|
||||
assert.Equal(t, int32(1), queryRes.ActiveVersion)
|
||||
assert.Equal(t, int32(1), queryRes.LatestVersion)
|
||||
assert.Equal(t, "", *queryRes.Config)
|
||||
assert.Equal(t, []string(nil), queryRes.RequiredQueries)
|
||||
|
||||
res, err := client.Update(ctx, &serviceinterfaces.QueryUpdate{
|
||||
Id: id,
|
||||
Config: nil,
|
||||
ActiveVersion: nil,
|
||||
RequiredQueries: []string{},
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, res)
|
||||
|
||||
queryRes, err = client.Get(ctx, &serviceinterfaces.IdMessage{
|
||||
Id: id,
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, id, queryRes.Id)
|
||||
assert.Equal(t, serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL, queryRes.Type)
|
||||
assert.Equal(t, int32(1), queryRes.ActiveVersion)
|
||||
assert.Equal(t, int32(1), queryRes.LatestVersion)
|
||||
assert.Equal(t, "", *queryRes.Config)
|
||||
assert.Equal(t, []string(nil), queryRes.RequiredQueries)
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
||||
"queryorchestration/internal/test"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestQueryServiceTest(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
conn, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
defer cleanup()
|
||||
|
||||
client := serviceinterfaces.NewQueryServiceClient(conn)
|
||||
|
||||
idRes, err := client.Create(ctx, &serviceinterfaces.QueryCreate{
|
||||
Type: serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL,
|
||||
Config: nil,
|
||||
RequiredQueries: []string{},
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
id := idRes.GetId()
|
||||
assert.NotEmpty(t, id)
|
||||
|
||||
docId := uuid.New()
|
||||
|
||||
testRes, err := client.Test(ctx, &serviceinterfaces.QueryTestRequest{
|
||||
QueryId: id,
|
||||
DocumentId: docId.String(),
|
||||
QueryVersion: int32(1),
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, testRes)
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
||||
"queryorchestration/internal/test"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestQueryService(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
conn, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||||
defer cleanup()
|
||||
|
||||
client := serviceinterfaces.NewQueryServiceClient(conn)
|
||||
|
||||
config := ""
|
||||
reqQueries := []string{}
|
||||
idRes, err := client.Create(ctx, &serviceinterfaces.QueryCreate{
|
||||
Type: 1,
|
||||
Config: &config,
|
||||
RequiredQueries: reqQueries,
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
id := idRes.GetId()
|
||||
assert.NotEmpty(t, id)
|
||||
|
||||
// queryRes, err := client.Get(ctx, &serviceinterfaces.IdMessage{
|
||||
// Id: id,
|
||||
// })
|
||||
// log.Print(err)
|
||||
// assert.Nil(t, err)
|
||||
// assert.EqualExportedValues(t, serviceinterfaces.Query{
|
||||
// Id: id,
|
||||
// Type: serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL,
|
||||
// ActiveVersion: int32(1),
|
||||
// LatestVersion: int32(1),
|
||||
// Config: &config,
|
||||
// RequiredQueries: reqQueries,
|
||||
// }, *queryRes)
|
||||
|
||||
//QueryService - List, Update, Test
|
||||
//JobController - Create, Update, Get
|
||||
//Export - Trigger
|
||||
}
|
||||
Reference in New Issue
Block a user