diff --git a/.travis.yml b/.travis.yml index 9ededa1d..fa8d8b95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,16 +30,14 @@ language: go env: - TEST_SUITE=run-unit-tests GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch ALWAYS=1 - TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb:3.6 - - TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb:latest ALWAYS=1 - TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb:3.7 - - TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb-preview:3.8.0-nightly - - TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb-preview:3.9.0-nightly - - TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb-preview:latest + - TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb:3.8 + - TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb:latest ALWAYS=1 + - TEST_SUITE=run-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb-preview:latest TEST_DISALLOW_UNKNOWN_FIELDS=false - TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb:3.6 - - TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb:latest ALWAYS=1 - TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb:3.7 - - TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb-preview:3.8.0-nightly - - TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb-preview:3.9.0-nightly + - TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb:3.8 + - TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb:latest ALWAYS=1 - TEST_SUITE=run-v2-tests-single GOIMAGE=gcr.io/gcr-for-testing/golang:1.16.6-stretch STARTER=gcr.io/gcr-for-testing/arangodb/arangodb-starter:latest ALPINE_IMAGE=gcr.io/gcr-for-testing/alpine:3.4 ARANGODB=gcr.io/gcr-for-testing/arangodb/arangodb-preview:latest script: diff --git a/Makefile b/Makefile index e9a421ac..5aa25780 100644 --- a/Makefile +++ b/Makefile @@ -382,6 +382,7 @@ __test_go_test: -e TEST_DEBUG='$(TEST_DEBUG)' \ -e TEST_ENABLE_SHUTDOWN=$(TEST_ENABLE_SHUTDOWN) \ -e TEST_REQUEST_LOG=$(TEST_REQUEST_LOG) \ + -e TEST_DISALLOW_UNKNOWN_FIELDS=$(TEST_DISALLOW_UNKNOWN_FIELDS) \ -e GODEBUG=tls13=1 \ -e CGO_ENABLED=$(CGO_ENABLED) \ -w /usr/code/ \ diff --git a/http/connection_wrapper.go b/http/connection_wrapper.go new file mode 100644 index 00000000..5f09e1bb --- /dev/null +++ b/http/connection_wrapper.go @@ -0,0 +1,91 @@ +package http + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "reflect" + "strings" + + "github.com/arangodb/go-driver" + "github.com/arangodb/go-velocypack" +) + +type connectionDebugWrapper struct { + driver.Connection + ct driver.ContentType +} + +func NewConnectionDebugWrapper(conn driver.Connection, ct driver.ContentType) driver.Connection { + return &connectionDebugWrapper{conn, ct} +} + +func (c *connectionDebugWrapper) Do(ctx context.Context, req driver.Request) (driver.Response, error) { + if c.ct == driver.ContentTypeJSON { + resp, err := c.Connection.Do(ctx, req) + if err != nil { + return resp, err + } + + httpResponse, ok := resp.(*httpJSONResponse) + if !ok { + panic("can not cast response to the httpJSONResponse type!") + } + + return &responseDebugWrapper{httpResponse}, err + + } + return c.Connection.Do(ctx, req) +} + +func (c *connectionDebugWrapper) Unmarshal(data driver.RawObject, result interface{}) error { + ct := c.ct + if ct == driver.ContentTypeVelocypack && len(data) >= 2 { + // Poor mans auto detection of json + l := len(data) + if (data[0] == '{' && data[l-1] == '}') || (data[0] == '[' && data[l-1] == ']') { + ct = driver.ContentTypeJSON + } + } + switch ct { + case driver.ContentTypeJSON: + decoder := json.NewDecoder(strings.NewReader(string(data))) + decoder.DisallowUnknownFields() + + if err := decoder.Decode(result); err != nil { + return driver.WithStack(err) + } + + if err := json.Unmarshal(data, result); err != nil { + fmt.Printf("Struct: %s \n", reflect.TypeOf(result).String()) + fmt.Printf("Response: %s \n\n", string(data)) + return driver.WithStack(errors.New(fmt.Sprintf("Struct: %s, Error: %s", reflect.TypeOf(result).String(), err.Error()))) + } + case driver.ContentTypeVelocypack: + if err := velocypack.Unmarshal(velocypack.Slice(data), result); err != nil { + return driver.WithStack(err) + } + default: + return driver.WithStack(fmt.Errorf("unsupported content type %d", int(c.ct))) + } + return nil +} + +type responseDebugWrapper struct { + *httpJSONResponse +} + +func (r *responseDebugWrapper) ParseBody(field string, result interface{}) error { + if field == "" { + decoder := json.NewDecoder(strings.NewReader(string(r.httpJSONResponse.rawResponse))) + decoder.DisallowUnknownFields() + + if err := decoder.Decode(result); err != nil { + fmt.Printf("Struct: %s \n", reflect.TypeOf(result).String()) + fmt.Printf("Response: %s \n\n", string(r.httpJSONResponse.rawResponse)) + return driver.WithStack(errors.New(fmt.Sprintf("Struct: %s, Error: %s", reflect.TypeOf(result).String(), err.Error()))) + } + } + return r.httpJSONResponse.ParseBody(field, result) +} diff --git a/test/client_test.go b/test/client_test.go index d4de0996..fbf107b7 100644 --- a/test/client_test.go +++ b/test/client_test.go @@ -160,6 +160,15 @@ func createConnectionFromEnvWitLog(t testEnv, logger zerolog.Logger) driver.Conn // createConnectionFromEnv initializes a Connection from information specified in environment variables. func createConnectionFromEnv(t testEnv) driver.Connection { + disallowUnknownFields := os.Getenv("TEST_DISALLOW_UNKNOWN_FIELDS") + if disallowUnknownFields == "true" { + return createConnection(t, true) + } + return createConnection(t, false) +} + +// createConnection initializes a Connection from information specified in environment variables. +func createConnection(t testEnv, disallowUnknownFields bool) driver.Connection { connSpec := os.Getenv("TEST_CONNECTION") connVer := os.Getenv("TEST_CVERSION") switch connSpec { @@ -184,6 +193,9 @@ func createConnectionFromEnv(t testEnv) driver.Connection { if err != nil { t.Fatalf("Failed to create new vst connection: %s", describe(err)) } + if disallowUnknownFields { + return http.NewConnectionDebugWrapper(conn, driver.ContentTypeVelocypack) + } return conn case "http", "": @@ -196,6 +208,9 @@ func createConnectionFromEnv(t testEnv) driver.Connection { if err != nil { t.Fatalf("Failed to create new http connection: %s", describe(err)) } + if disallowUnknownFields { + return http.NewConnectionDebugWrapper(conn, config.ContentType) + } return conn default: @@ -206,6 +221,15 @@ func createConnectionFromEnv(t testEnv) driver.Connection { // createClientFromEnv initializes a Client from information specified in environment variables. func createClientFromEnv(t testEnv, waitUntilReady bool) driver.Client { + disallowUnknownFields := os.Getenv("TEST_DISALLOW_UNKNOWN_FIELDS") + if disallowUnknownFields == "true" { + return createClient(t, waitUntilReady, true) + } + return createClient(t, waitUntilReady, false) +} + +// createClient initializes a Client from information specified in environment variables. +func createClient(t testEnv, waitUntilReady bool, disallowUnknownFields bool) driver.Client { runPProfServerOnce.Do(func() { if os.Getenv("TEST_PPROF") != "" { go func() { @@ -217,7 +241,7 @@ func createClientFromEnv(t testEnv, waitUntilReady bool) driver.Client { } }) - conn := createConnectionFromEnv(t) + conn := createConnection(t, disallowUnknownFields) if os.Getenv("TEST_REQUEST_LOG") != "" { conn = WrapLogger(t, conn) } diff --git a/test/collection_test.go b/test/collection_test.go index c2a110d6..c0652d34 100644 --- a/test/collection_test.go +++ b/test/collection_test.go @@ -376,7 +376,8 @@ func TestCollectionName(t *testing.T) { // TestCollectionTruncate creates a collection, adds some documents and truncates it. func TestCollectionTruncate(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "collection_test", nil, t) name := "test_collection_truncate" col, err := db.CreateCollection(nil, name, nil) diff --git a/test/concurrency_test.go b/test/concurrency_test.go index 3747d667..f3ce8587 100644 --- a/test/concurrency_test.go +++ b/test/concurrency_test.go @@ -40,7 +40,14 @@ func TestConcurrentCreateSmallDocuments(t *testing.T) { if testing.Short() { t.Skip("Skip on short tests") } - c := createClientFromEnv(t, true) + + // Disable those tests for active failover + if getTestMode() == testModeResilientSingle { + t.Skip("Disabled in active failover mode") + } + + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) version, err := c.Version(nil) if err != nil { @@ -124,7 +131,14 @@ func TestConcurrentCreateBigDocuments(t *testing.T) { if testing.Short() { t.Skip("Skip on short tests") } - c := createClientFromEnv(t, true) + + // Disable those tests for active failover + if getTestMode() == testModeResilientSingle { + t.Skip("Disabled in active failover mode") + } + + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) version, err := c.Version(nil) if err != nil { diff --git a/test/cursor_test.go b/test/cursor_test.go index de1e7358..b369bccd 100644 --- a/test/cursor_test.go +++ b/test/cursor_test.go @@ -85,7 +85,8 @@ func TestCreateCursorWithMaxRuntime(t *testing.T) { // TestCreateCursor creates several cursors. func TestCreateCursor(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "cursor_test", nil, t) // Create data set @@ -327,7 +328,8 @@ func TestCreateCursorReturnNull(t *testing.T) { func TestCreateStreamCursor(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) version, err := c.Version(nil) if err != nil { diff --git a/test/document_create_test.go b/test/document_create_test.go index c9a2fadd..4699783f 100644 --- a/test/document_create_test.go +++ b/test/document_create_test.go @@ -41,7 +41,8 @@ func createDocument(ctx context.Context, col driver.Collection, document interfa // TestCreateDocument creates a document and then checks that it exists. func TestCreateDocument(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "document_test", nil, t) col := ensureCollection(nil, db, "document_test", nil, t) doc := UserDoc{ @@ -70,7 +71,8 @@ func TestCreateDocument(t *testing.T) { // TestCreateDocumentWithKey creates a document with given key and then checks that it exists. func TestCreateDocumentWithKey(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "document_test", nil, t) col := ensureCollection(nil, db, "document_withKey_test", nil, t) doc := UserDocWithKey{ @@ -104,7 +106,8 @@ func TestCreateDocumentWithKey(t *testing.T) { // TestCreateDocumentReturnNew creates a document and checks the document returned in in ReturnNew. func TestCreateDocumentReturnNew(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "document_test", nil, t) doc := UserDoc{ @@ -160,7 +163,8 @@ func TestCreateDocumentNil(t *testing.T) { // TestCreateDocumentInWaitForSyncCollection creates a document in a collection with waitForSync enabled, // and then checks that it exists. func TestCreateDocumentInWaitForSyncCollection(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "document_test", nil, t) col := ensureCollection(nil, db, "TestCreateDocumentInWaitForSyncCollection", &driver.CreateCollectionOptions{ WaitForSync: true, diff --git a/test/document_read_test.go b/test/document_read_test.go index 20873916..1c37a763 100644 --- a/test/document_read_test.go +++ b/test/document_read_test.go @@ -31,7 +31,8 @@ import ( // TestReadDocumentWithIfMatch creates a document and reads it with a non-matching revision. func TestReadDocumentWithIfMatch(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "document_read_test", nil, t) col := ensureCollection(nil, db, "document_read_test", nil, t) doc := UserDoc{ @@ -50,7 +51,7 @@ func TestReadDocumentWithIfMatch(t *testing.T) { if err != nil { t.Fatalf("Failed to read document: %s", describe(err)) } - if meta2 != meta { + if meta2.Key != meta.Key || meta2.Rev != meta.Rev || meta2.ID != meta.ID { t.Error("Read wrong meta data.") } diff --git a/test/document_remove_test.go b/test/document_remove_test.go index bd01d199..cb768977 100644 --- a/test/document_remove_test.go +++ b/test/document_remove_test.go @@ -63,7 +63,8 @@ func TestRemoveDocument(t *testing.T) { // TestRemoveDocumentReturnOld creates a document, removes it checks the ReturnOld value. func TestRemoveDocumentReturnOld(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "document_test", nil, t) doc := UserDoc{ @@ -174,7 +175,8 @@ func TestRemoveDocumentKeyEmpty(t *testing.T) { // removes it and then checks the removal has succeeded. func TestRemoveDocumentInWaitForSyncCollection(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "TestRemoveDocumentInWaitForSyncCollection", &driver.CreateCollectionOptions{ WaitForSync: true, diff --git a/test/document_replace_test.go b/test/document_replace_test.go index d033e219..b84db19d 100644 --- a/test/document_replace_test.go +++ b/test/document_replace_test.go @@ -33,7 +33,8 @@ import ( // TestReplaceDocument creates a document, replaces it and then checks the replacement has succeeded. func TestReplaceDocument(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "document_test", nil, t) doc := UserDoc{ @@ -65,7 +66,8 @@ func TestReplaceDocument(t *testing.T) { // TestReplaceDocumentReturnOld creates a document, replaces it checks the ReturnOld value. func TestReplaceDocumentReturnOld(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "document_test", nil, t) doc := UserDoc{ @@ -94,7 +96,8 @@ func TestReplaceDocumentReturnOld(t *testing.T) { // TestReplaceDocumentReturnNew creates a document, replaces it checks the ReturnNew value. func TestReplaceDocumentReturnNew(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "document_test", nil, t) doc := UserDoc{ @@ -219,7 +222,8 @@ func TestReplaceDocumentUpdateNil(t *testing.T) { // replaces it and then checks the replacement has succeeded. func TestReplaceDocumentInWaitForSyncCollection(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "TestReplaceDocumentInWaitForSyncCollection", &driver.CreateCollectionOptions{ WaitForSync: true, diff --git a/test/document_update_test.go b/test/document_update_test.go index d5950fc1..d6f08eb0 100644 --- a/test/document_update_test.go +++ b/test/document_update_test.go @@ -33,7 +33,8 @@ import ( // TestUpdateDocument1 creates a document, updates it and then checks the update has succeeded. func TestUpdateDocument1(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "document_test", nil, t) doc := UserDoc{ @@ -65,7 +66,8 @@ func TestUpdateDocument1(t *testing.T) { // TestUpdateDocumentReturnOld creates a document, updates it checks the ReturnOld value. func TestUpdateDocumentReturnOld(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "document_test", nil, t) doc := UserDoc{ @@ -94,7 +96,8 @@ func TestUpdateDocumentReturnOld(t *testing.T) { // TestUpdateDocumentReturnNew creates a document, updates it checks the ReturnNew value. func TestUpdateDocumentReturnNew(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "document_test", nil, t) doc := UserDoc{ @@ -125,7 +128,8 @@ func TestUpdateDocumentReturnNew(t *testing.T) { // TestUpdateDocumentKeepNullTrue creates a document, updates it with KeepNull(true) and then checks the update has succeeded. func TestUpdateDocumentKeepNullTrue(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) conn := c.Connection() db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "document_test", nil, t) @@ -171,7 +175,8 @@ func TestUpdateDocumentKeepNullTrue(t *testing.T) { // TestUpdateDocumentKeepNullFalse creates a document, updates it with KeepNull(false) and then checks the update has succeeded. func TestUpdateDocumentKeepNullFalse(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "document_test", nil, t) doc := Account{ @@ -301,7 +306,8 @@ func TestUpdateDocumentUpdateNil(t *testing.T) { // updates it and then checks the update has succeeded. func TestUpdateDocumentInWaitForSyncCollection(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "TestUpdateDocumentInWaitForSyncCollection", &driver.CreateCollectionOptions{ WaitForSync: true, diff --git a/test/documents_create_overwrite_test.go b/test/documents_create_overwrite_test.go index ff4adbad..7c4d9d36 100644 --- a/test/documents_create_overwrite_test.go +++ b/test/documents_create_overwrite_test.go @@ -43,7 +43,8 @@ func generateIDs(count int) []string { // TestCreateOverwriteDocument creates a document and then checks that it exists. Check with overwrite flag. func TestCreateOverwriteDocument(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -94,7 +95,8 @@ func TestCreateOverwriteDocument(t *testing.T) { // TestCreateOverwriteModeDocument creates a document and then checks that it exists. Check with overwriteMode flag. func TestCreateOverwriteModeDocument(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/test/documents_create_test.go b/test/documents_create_test.go index 1ee066ac..60f849a7 100644 --- a/test/documents_create_test.go +++ b/test/documents_create_test.go @@ -32,7 +32,8 @@ import ( // TestCreateDocuments creates a document and then checks that it exists. func TestCreateDocuments(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "document_test", nil, t) col := ensureCollection(nil, db, "documents_test", nil, t) docs := []UserDoc{ @@ -90,7 +91,8 @@ func TestCreateDocuments(t *testing.T) { // TestCreateDocumentsReturnNew creates a document and checks the document returned in in ReturnNew. func TestCreateDocumentsReturnNew(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "documents_test", nil, t) docs := []UserDoc{ @@ -185,7 +187,8 @@ func TestCreateDocumentsNonSlice(t *testing.T) { // TestCreateDocumentsInWaitForSyncCollection creates a few documents in a collection with waitForSync enabled and then checks that it exists. func TestCreateDocumentsInWaitForSyncCollection(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "document_test", nil, t) col := ensureCollection(nil, db, "TestCreateDocumentsInWaitForSyncCollection", &driver.CreateCollectionOptions{ WaitForSync: true, diff --git a/test/documents_import_test.go b/test/documents_import_test.go index 414fb793..85297d4f 100644 --- a/test/documents_import_test.go +++ b/test/documents_import_test.go @@ -112,7 +112,8 @@ func TestImportDocumentsEmptyEntries(t *testing.T) { if getContentTypeFromEnv(t) == driver.ContentTypeVelocypack { t.Skip("Not supported on vpack") } - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "document_test", nil, t) col := ensureCollection(nil, db, "import_emptyEntries_test", nil, t) docs := []*UserDocWithKey{ @@ -270,7 +271,8 @@ func TestImportDocumentsDuplicateEntriesComplete(t *testing.T) { // TestImportDocumentsDuplicateEntriesUpdate imports documents and then checks that it exists. func TestImportDocumentsDuplicateEntriesUpdate(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "document_test", nil, t) col := ensureCollection(nil, db, "import_duplicateEntriesUpdate_test", nil, t) docs := []interface{}{ @@ -325,7 +327,8 @@ func TestImportDocumentsDuplicateEntriesUpdate(t *testing.T) { // TestImportDocumentsDuplicateEntriesReplace imports documents and then checks that it exists. func TestImportDocumentsDuplicateEntriesReplace(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "document_test", nil, t) col := ensureCollection(nil, db, "import_duplicateEntriesReplace_test", nil, t) docs := []interface{}{ @@ -380,7 +383,8 @@ func TestImportDocumentsDuplicateEntriesReplace(t *testing.T) { // TestImportDocumentsDuplicateEntriesIgnore imports documents and then checks that it exists. func TestImportDocumentsDuplicateEntriesIgnore(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "document_test", nil, t) col := ensureCollection(nil, db, "import_duplicateEntriesIgnore_test", nil, t) docs := []interface{}{ @@ -435,7 +439,8 @@ func TestImportDocumentsDuplicateEntriesIgnore(t *testing.T) { // TestImportDocumentsDetails imports documents and then checks that it exists. func TestImportDocumentsDetails(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "document_test", nil, t) col := ensureCollection(nil, db, "import_details_test", nil, t) docs := []interface{}{ @@ -484,7 +489,8 @@ func TestImportDocumentsDetails(t *testing.T) { // TestImportDocumentsOverwriteYes imports documents and then checks that it exists. func TestImportDocumentsOverwriteYes(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "document_test", nil, t) col := ensureCollection(nil, db, "import_overwriteYes_test", nil, t) docs := []interface{}{ @@ -523,7 +529,8 @@ func TestImportDocumentsOverwriteYes(t *testing.T) { // TestImportDocumentsOverwriteNo imports documents and then checks that it exists. func TestImportDocumentsOverwriteNo(t *testing.T) { - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(nil, c, "document_test", nil, t) col := ensureCollection(nil, db, "import_overwriteNo_test", nil, t) docs := []interface{}{ diff --git a/test/documents_replace_test.go b/test/documents_replace_test.go index 19748560..68cd68ec 100644 --- a/test/documents_replace_test.go +++ b/test/documents_replace_test.go @@ -34,7 +34,8 @@ import ( // TestReplaceDocuments creates documents, replaces them and then checks the replacements have succeeded. func TestReplaceDocuments(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "documents_test", nil, t) docs := []UserDoc{ @@ -334,7 +335,8 @@ func TestReplaceDocumentsUpdateLenDiff(t *testing.T) { // replaces them and then checks the replacements have succeeded. func TestReplaceDocumentsInWaitForSyncCollection(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "TestReplaceDocumentsInWaitForSyncCollection", &driver.CreateCollectionOptions{ WaitForSync: true, diff --git a/test/documents_update_test.go b/test/documents_update_test.go index 25cb825d..ab07221c 100644 --- a/test/documents_update_test.go +++ b/test/documents_update_test.go @@ -35,7 +35,8 @@ import ( // TestUpdateDocuments1 creates documents, updates them and then checks the updates have succeeded. func TestUpdateDocuments1(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "documents_test", nil, t) docs := []UserDoc{ @@ -187,7 +188,8 @@ func TestUpdateDocumentsReturnNew(t *testing.T) { // TestUpdateDocumentsKeepNullTrue creates documents, updates them with KeepNull(true) and then checks the updates have succeeded. func TestUpdateDocumentsKeepNullTrue(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) conn := c.Connection() db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "documents_test", nil, t) @@ -253,7 +255,8 @@ func TestUpdateDocumentsKeepNullTrue(t *testing.T) { // TestUpdateDocumentsKeepNullFalse creates documents, updates them with KeepNull(false) and then checks the updates have succeeded. func TestUpdateDocumentsKeepNullFalse(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "documents_test", nil, t) docs := []Account{ @@ -457,7 +460,8 @@ func TestUpdateDocumentsUpdateLenDiff(t *testing.T) { // updates them and then checks the updates have succeeded. func TestUpdateDocumentsInWaitForSyncCollection(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "document_test", nil, t) col := ensureCollection(ctx, db, "TestUpdateDocumentsInWaitForSyncCollection", &driver.CreateCollectionOptions{ WaitForSync: true, diff --git a/test/edges_import_test.go b/test/edges_import_test.go index 55c46f9b..6b6e46d9 100644 --- a/test/edges_import_test.go +++ b/test/edges_import_test.go @@ -598,7 +598,8 @@ func TestImportEdgesDetails(t *testing.T) { // TestImportEdgesOverwriteYes imports documents and then checks that it exists. func TestImportEdgesOverwriteYes(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "edges_test", nil, t) prefix := "import_edges_overwriteYes_" g := ensureGraph(ctx, db, prefix+"graph", nil, t) @@ -647,7 +648,8 @@ func TestImportEdgesOverwriteYes(t *testing.T) { // TestImportEdgesOverwriteNo imports documents and then checks that it exists. func TestImportEdgesOverwriteNo(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "edges_test", nil, t) prefix := "import_edges_overwriteNo_" g := ensureGraph(ctx, db, prefix+"graph", nil, t) @@ -696,7 +698,8 @@ func TestImportEdgesOverwriteNo(t *testing.T) { // TestImportEdgesPrefix imports documents and then checks that it exists. func TestImportEdgesPrefix(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "edges_test", nil, t) prefix := "import_edges_prefix_" g := ensureGraph(ctx, db, prefix+"graph", nil, t) diff --git a/test/vertices_import_test.go b/test/vertices_import_test.go index cc3edfb7..a96f4e6d 100644 --- a/test/vertices_import_test.go +++ b/test/vertices_import_test.go @@ -506,7 +506,8 @@ func TestImportVerticesDetails(t *testing.T) { // TestImportVerticesOverwriteYes imports documents and then checks that it exists. func TestImportVerticesOverwriteYes(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "vertices_test", nil, t) g := ensureGraph(ctx, db, "import_vertices_test", nil, t) col := ensureVertexCollection(nil, g, "import_overwriteYes_test", t) @@ -547,7 +548,8 @@ func TestImportVerticesOverwriteYes(t *testing.T) { // TestImportVerticesOverwriteNo imports documents and then checks that it exists. func TestImportVerticesOverwriteNo(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) db := ensureDatabase(ctx, c, "vertices_test", nil, t) g := ensureGraph(ctx, db, "import_vertices_test", nil, t) col := ensureVertexCollection(nil, g, "import_overwriteNo_test", t) diff --git a/test/view_test.go b/test/view_test.go index 46390dda..0d68edf7 100644 --- a/test/view_test.go +++ b/test/view_test.go @@ -426,7 +426,8 @@ func TestRemoveArangoSearchView(t *testing.T) { // an AQL query. func TestUseArangoSearchView(t *testing.T) { ctx := context.Background() - c := createClientFromEnv(t, true) + // don't use disallowUnknownFields in this test - we have here custom structs defined + c := createClient(t, true, false) skipBelowVersion(c, "3.4", t) db := ensureDatabase(nil, c, "view_test", nil, t) col := ensureCollection(ctx, db, "some_collection", nil, t)