Merged in bugfix/tests (pull request #107)
Fix Fullsuite * save * foundthefix.. * codeandrequire
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"queryorchestration/internal/test"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -20,22 +22,22 @@ func TestQueryAPIAccessories(t *testing.T) {
|
||||
defer cleanup()
|
||||
|
||||
resp, err := http.Get(fmt.Sprintf("%s/swagger/doc.json", c.URI))
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get(fmt.Sprintf("%s/swagger/doc.yaml", c.URI))
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get(fmt.Sprintf("%s/swagger/index.html", c.URI))
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
resp, err = http.Get(fmt.Sprintf("%s/metrics", c.URI))
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
queryapi "queryorchestration/pkg/queryAPI"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestClient(t *testing.T) {
|
||||
@@ -20,10 +21,10 @@ func TestClient(t *testing.T) {
|
||||
defer cleanup()
|
||||
|
||||
client, err := queryapi.NewClientWithResponses(c.URI)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
|
||||
clientErrRes, err := client.GetClientWithResponse(ctx, "INVALID")
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, http.StatusBadRequest, clientErrRes.StatusCode())
|
||||
assert.Equal(t, "Unable to get client: no rows in result set", clientErrRes.JSON400.Message)
|
||||
|
||||
@@ -31,14 +32,15 @@ func TestClient(t *testing.T) {
|
||||
Name: "example_name",
|
||||
Id: "EXA",
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, idRes)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusCreated, idRes.StatusCode())
|
||||
assert.NotNil(t, idRes.JSON201)
|
||||
assert.NotNil(t, idRes.JSON201.Id)
|
||||
assert.Equal(t, "EXA", idRes.JSON201.Id)
|
||||
id := idRes.JSON201.Id
|
||||
|
||||
clientRes, err := client.GetClientWithResponse(ctx, id)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, clientRes.StatusCode())
|
||||
assert.Equal(t, id, clientRes.JSON200.Id)
|
||||
assert.Equal(t, "example_name", clientRes.JSON200.Name)
|
||||
assert.False(t, clientRes.JSON200.CanSync)
|
||||
@@ -49,11 +51,11 @@ func TestClient(t *testing.T) {
|
||||
Name: &updateName,
|
||||
CanSync: &updateCanSync,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, updateRes)
|
||||
|
||||
clientRes, err = client.GetClientWithResponse(ctx, id)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, id, clientRes.JSON200.Id)
|
||||
assert.Equal(t, updateName, clientRes.JSON200.Name)
|
||||
assert.True(t, clientRes.JSON200.CanSync)
|
||||
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
"queryorchestration/internal/test"
|
||||
queryapi "queryorchestration/pkg/queryAPI"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/oapi-codegen/runtime/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -45,12 +47,12 @@ func TestCollectorService(t *testing.T) {
|
||||
defer cleanup()
|
||||
|
||||
client, err := queryapi.NewClientWithResponses(c.URI)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
|
||||
contextRes, err := client.CreateQueryWithResponse(ctx, queryapi.QueryCreate{
|
||||
Type: queryapi.CONTEXTFULL,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
|
||||
jsoncfg := "{\"path\":\"key\"}"
|
||||
jsonRes, err := client.CreateQueryWithResponse(ctx, queryapi.QueryCreate{
|
||||
@@ -60,17 +62,17 @@ func TestCollectorService(t *testing.T) {
|
||||
contextRes.JSON201.Id,
|
||||
},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
|
||||
clientRes, err := client.CreateClientWithResponse(ctx, queryapi.ClientCreate{
|
||||
Name: "example_name",
|
||||
Id: "ID",
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
id := clientRes.JSON201.Id
|
||||
|
||||
collRes, err := client.GetCollectorByClientIdWithResponse(ctx, id)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, id, collRes.JSON200.ClientId)
|
||||
assert.Equal(t, int32(0), collRes.JSON200.ActiveVersion)
|
||||
assert.Equal(t, int32(0), collRes.JSON200.LatestVersion)
|
||||
@@ -92,11 +94,11 @@ func TestCollectorService(t *testing.T) {
|
||||
MinimumTextVersion: &minVersion,
|
||||
Fields: &fields,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 200, uRes.StatusCode())
|
||||
|
||||
collRes, err = client.GetCollectorByClientIdWithResponse(ctx, id)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, id, collRes.JSON200.ClientId)
|
||||
assert.Equal(t, int32(1), collRes.JSON200.ActiveVersion)
|
||||
assert.Equal(t, int32(1), collRes.JSON200.LatestVersion)
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"queryorchestration/internal/test"
|
||||
queryapi "queryorchestration/pkg/queryAPI"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -19,9 +21,9 @@ func TestExportService(t *testing.T) {
|
||||
defer cleanup()
|
||||
|
||||
client, err := queryapi.NewClientWithResponses(c.URI)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
|
||||
idRes, err := client.TriggerExportWithResponse(ctx, "CLIENT_ID", queryapi.ExportTrigger{})
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, idRes)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import (
|
||||
"queryorchestration/internal/test"
|
||||
queryapi "queryorchestration/pkg/queryAPI"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/oapi-codegen/runtime/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -38,7 +40,7 @@ func TestQueryAPI(t *testing.T) {
|
||||
defer clean()
|
||||
|
||||
err := cfg.SetQueueClient(ctx)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
queryversionsyncurl := test.CreateQueue(t, ctx, cfg, test.QueryVersionSyncRunnerName)
|
||||
|
||||
c, cleanup := test.CreateAPINetwork(t, ctx, &test.ServiceNetworkConfig{
|
||||
@@ -49,12 +51,12 @@ func TestQueryAPI(t *testing.T) {
|
||||
defer cleanup()
|
||||
|
||||
client, err := queryapi.NewClientWithResponses(c.URI)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
|
||||
idRes, err := client.CreateQueryWithResponse(ctx, queryapi.QueryCreate{
|
||||
Type: queryapi.CONTEXTFULL,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, idRes)
|
||||
assert.NotNil(t, idRes.JSON201)
|
||||
contextID := idRes.JSON201.Id
|
||||
@@ -65,11 +67,13 @@ func TestQueryAPI(t *testing.T) {
|
||||
Type: queryapi.JSONEXTRACTOR,
|
||||
Config: &jcfg,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, idRes)
|
||||
assert.NotNil(t, idRes.JSON201)
|
||||
jsonID := idRes.JSON201.Id
|
||||
|
||||
queryRes, err := client.GetQueryWithResponse(ctx, jsonID)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, jsonID, queryRes.JSON200.Id)
|
||||
assert.Equal(t, queryapi.JSONEXTRACTOR, queryRes.JSON200.Type)
|
||||
assert.Equal(t, int32(1), queryRes.JSON200.ActiveVersion)
|
||||
@@ -78,7 +82,7 @@ func TestQueryAPI(t *testing.T) {
|
||||
assert.Nil(t, queryRes.JSON200.RequiredQueries)
|
||||
|
||||
queriesRes, err := client.ListQueriesWithResponse(ctx)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, queriesRes.JSON200.Queries, 2)
|
||||
|
||||
aV := int32(2)
|
||||
@@ -88,13 +92,13 @@ func TestQueryAPI(t *testing.T) {
|
||||
contextID,
|
||||
},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, res)
|
||||
|
||||
test.AssertMessageBody(t, ctx, cfg, queryversionsyncurl, regexp.MustCompile(`{"id":".+"}`))
|
||||
|
||||
queryRes, err = client.GetQueryWithResponse(ctx, jsonID)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, jsonID, queryRes.JSON200.Id)
|
||||
assert.Equal(t, queryapi.JSONEXTRACTOR, queryRes.JSON200.Type)
|
||||
assert.Equal(t, int32(2), queryRes.JSON200.ActiveVersion)
|
||||
|
||||
Reference in New Issue
Block a user