Merged in feature/import (pull request #157)
Feature/import * importstart * pp * tests * importtests * 100GB * lint * passtests * utc * awsprofile * doublequotes * host
This commit is contained in:
+10
-13
@@ -1,16 +1,14 @@
|
||||
package queryapi_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
queryapi "queryorchestration/api/queryAPI"
|
||||
"queryorchestration/internal/database/repository"
|
||||
"queryorchestration/internal/serviceconfig"
|
||||
"queryorchestration/internal/serviceconfig/queue/clientsync"
|
||||
"queryorchestration/internal/test"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
@@ -18,11 +16,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type ClientConfig struct {
|
||||
serviceconfig.BaseConfig
|
||||
clientsync.ClientSyncConfig
|
||||
}
|
||||
|
||||
func TestCreateClient(t *testing.T) {
|
||||
t.Parallel()
|
||||
cfg := &ControllerConfig{}
|
||||
@@ -36,7 +29,7 @@ func TestCreateClient(t *testing.T) {
|
||||
Id: "external_id",
|
||||
}
|
||||
|
||||
ctx, rec := createContextWithBody(t, body)
|
||||
ctx, rec := createContextWithJSONBody(t, body)
|
||||
|
||||
err := cons.CreateClient(ctx)
|
||||
require.NoError(t, err)
|
||||
@@ -105,7 +98,7 @@ func TestUpdateClient(t *testing.T) {
|
||||
Name: &newClientName,
|
||||
}
|
||||
|
||||
ctx, rec := createContextWithBody(t, body)
|
||||
ctx, rec := createContextWithJSONBody(t, body)
|
||||
|
||||
err = cons.UpdateClient(ctx, id)
|
||||
require.NoError(t, err)
|
||||
@@ -118,15 +111,19 @@ func TestUpdateClient(t *testing.T) {
|
||||
}
|
||||
|
||||
func createContext(t testing.TB) (echo.Context, *httptest.ResponseRecorder) {
|
||||
return createContextWithBody(t, struct{}{})
|
||||
return createContextWithJSONBody(t, struct{}{})
|
||||
}
|
||||
|
||||
func createContextWithBody(t testing.TB, body interface{}) (echo.Context, *httptest.ResponseRecorder) {
|
||||
func createContextWithJSONBody(t testing.TB, body interface{}) (echo.Context, *httptest.ResponseRecorder) {
|
||||
bodyBytes, err := json.Marshal(body)
|
||||
require.NoError(t, err)
|
||||
|
||||
return createContextWithBody(t, bodyBytes)
|
||||
}
|
||||
|
||||
func createContextWithBody(t testing.TB, body []byte) (echo.Context, *httptest.ResponseRecorder) {
|
||||
e := echo.New()
|
||||
req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(string(bodyBytes)))
|
||||
req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(body))
|
||||
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
|
||||
rec := httptest.NewRecorder()
|
||||
return e.NewContext(req, rec), rec
|
||||
|
||||
Reference in New Issue
Block a user