From 85cb16750165c82295841be09aca7f2ca253299f Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Thu, 3 Oct 2024 14:14:26 +0200 Subject: [PATCH 1/5] Expose `NewT` method --- CHANGELOG.md | 1 + test/arangosearch_analyzers_test.go | 60 ++++++------ test/collection_test.go | 12 ++- test/index_ensure_test.go | 14 +-- test/view_alias_test.go | 8 +- test/view_test.go | 34 ++++--- util/type.go | 25 +++++ v2/CHANGELOG.md | 1 + v2/tests/admin_log_test.go | 6 +- v2/tests/admin_test.go | 8 +- v2/tests/asyncjob_test.go | 8 +- v2/tests/backup_test.go | 10 +- v2/tests/database_analyzer_test.go | 92 ++++++++++--------- .../database_collection_doc_create_test.go | 36 ++++---- .../database_collection_doc_delete_test.go | 22 +++-- v2/tests/database_collection_doc_read_test.go | 12 ++- .../database_collection_doc_replace_test.go | 30 +++--- .../database_collection_doc_update_test.go | 38 ++++---- v2/tests/database_collection_indexes_test.go | 42 +++++---- .../database_collection_operations_test.go | 12 ++- v2/tests/database_collection_perf_test.go | 6 +- .../database_view-arangosearch-simple_test.go | 10 +- v2/tests/database_view-arangosearch_test.go | 34 +++---- v2/tests/graph_edge_definitions_edges_test.go | 14 +-- v2/tests/graph_edge_definitions_test.go | 4 +- v2/tests/graph_helper_test.go | 4 +- v2/tests/graph_test.go | 8 +- v2/tests/graph_vertex_collections_test.go | 4 +- .../graph_vertex_collections_vertices_test.go | 8 +- v2/tests/helper_test.go | 20 +--- v2/tests/users_permissions_test.go | 4 +- v2/tests/users_test.go | 12 ++- v2/utils/type.go | 12 ++- 33 files changed, 341 insertions(+), 270 deletions(-) create mode 100644 util/type.go diff --git a/CHANGELOG.md b/CHANGELOG.md index e742e1fb..e11c2af7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log ## [master](https://github.com/arangodb/go-driver/tree/master) (N/A) +- Expose `NewT` method ## [1.6.4(https://github.com/arangodb/go-driver/tree/v1.6.4) (2024-09-27) - Switch to Go 1.22.5 diff --git a/test/arangosearch_analyzers_test.go b/test/arangosearch_analyzers_test.go index 24682915..0eb1e4e2 100644 --- a/test/arangosearch_analyzers_test.go +++ b/test/arangosearch_analyzers_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2018-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2018-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ import ( "encoding/json" "testing" + "github.com/arangodb/go-driver/util" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver" @@ -139,7 +141,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: newBool(false), + PreserveOriginal: util.NewT(false), }, }, }, @@ -152,7 +154,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: newBool(false), + PreserveOriginal: util.NewT(false), }, }, ExpectedDefinition: &driver.ArangoSearchAnalyzerDefinition{ @@ -161,7 +163,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: newBool(false), + PreserveOriginal: util.NewT(false), // Check defaults for 3.6 StartMarker: newString(""), @@ -179,7 +181,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: newBool(false), + PreserveOriginal: util.NewT(false), StartMarker: newString("^"), EndMarker: newString("^"), StreamType: newArangoSearchNGramStreamType(driver.ArangoSearchNGramStreamUTF8), @@ -199,7 +201,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: newBool(false), + PreserveOriginal: util.NewT(false), StartMarker: newString("^"), EndMarker: newString("^"), StreamType: newArangoSearchNGramStreamType(driver.ArangoSearchNGramStreamUTF8), @@ -217,11 +219,11 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Type: driver.ArangoSearchAnalyzerTypeAQL, Properties: driver.ArangoSearchAnalyzerProperties{ QueryString: `FOR year IN [ 2011, 2012, 2013 ] FOR quarter IN [ 1, 2, 3, 4 ] RETURN { year, quarter, formatted: CONCAT(quarter, " / ", year)}`, - CollapsePositions: newBool(true), - KeepNull: newBool(false), - BatchSize: newInt(10), + CollapsePositions: util.NewT(true), + KeepNull: util.NewT(false), + BatchSize: util.NewT(10), ReturnType: driver.ArangoSearchAnalyzerAQLReturnTypeString.New(), - MemoryLimit: newInt(1024 * 1024), + MemoryLimit: util.NewT(1024 * 1024), }, }, }, @@ -233,9 +235,9 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Type: driver.ArangoSearchAnalyzerTypeGeoPoint, Properties: driver.ArangoSearchAnalyzerProperties{ Options: &driver.ArangoSearchAnalyzerGeoOptions{ - MaxCells: newInt(20), - MinLevel: newInt(4), - MaxLevel: newInt(23), + MaxCells: util.NewT(20), + MinLevel: util.NewT(4), + MaxLevel: util.NewT(23), }, Latitude: []string{}, Longitude: []string{}, @@ -250,9 +252,9 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Type: driver.ArangoSearchAnalyzerTypeGeoJSON, Properties: driver.ArangoSearchAnalyzerProperties{ Options: &driver.ArangoSearchAnalyzerGeoOptions{ - MaxCells: newInt(20), - MinLevel: newInt(4), - MaxLevel: newInt(23), + MaxCells: util.NewT(20), + MinLevel: util.NewT(4), + MaxLevel: util.NewT(23), }, Type: driver.ArangoSearchAnalyzerGeoJSONTypeShape.New(), }, @@ -267,9 +269,9 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Format: driver.FormatLatLngInt.New(), Options: &driver.ArangoSearchAnalyzerGeoOptions{ - MaxCells: newInt(20), - MinLevel: newInt(4), - MaxLevel: newInt(23), + MaxCells: util.NewT(20), + MinLevel: util.NewT(4), + MaxLevel: util.NewT(23), }, Type: driver.ArangoSearchAnalyzerGeoJSONTypeShape.New(), }, @@ -280,9 +282,9 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Format: driver.FormatLatLngInt.New(), Options: &driver.ArangoSearchAnalyzerGeoOptions{ - MaxCells: newInt(20), - MinLevel: newInt(4), - MaxLevel: newInt(23), + MaxCells: util.NewT(20), + MinLevel: util.NewT(4), + MaxLevel: util.NewT(23), }, Type: driver.ArangoSearchAnalyzerGeoJSONTypeShape.New(), }, @@ -326,7 +328,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Name: "my-stopWords", Type: driver.ArangoSearchAnalyzerTypeStopwords, Properties: driver.ArangoSearchAnalyzerProperties{ - Hex: newBool(true), + Hex: util.NewT(true), Stopwords: []string{ "616e64", "746865", @@ -337,7 +339,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Name: "my-stopWords", Type: driver.ArangoSearchAnalyzerTypeStopwords, Properties: driver.ArangoSearchAnalyzerProperties{ - Hex: newBool(true), + Hex: util.NewT(true), Stopwords: []string{ "616e64", "746865", @@ -356,7 +358,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Analyzer: &driver.ArangoSearchAnalyzerDefinition{ Type: driver.ArangoSearchAnalyzerTypeStopwords, Properties: driver.ArangoSearchAnalyzerProperties{ - Hex: newBool(true), + Hex: util.NewT(true), Stopwords: []string{ "616e64", "746865", @@ -373,7 +375,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Analyzer: &driver.ArangoSearchAnalyzerDefinition{ Type: driver.ArangoSearchAnalyzerTypeStopwords, Properties: driver.ArangoSearchAnalyzerProperties{ - Hex: newBool(true), + Hex: util.NewT(true), Stopwords: []string{ "616e64", "746865", @@ -450,7 +452,7 @@ func TestArangoSearchAnalyzerGet(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: newBool(false), + PreserveOriginal: util.NewT(false), }, } ensureAnalyzer(ctx, db, def, t) @@ -484,7 +486,7 @@ func TestArangoSearchAnalyzerGetAll(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: newBool(false), + PreserveOriginal: util.NewT(false), }, } ensureAnalyzer(ctx, db, def, t) @@ -524,7 +526,7 @@ func TestArangoSearchAnalyzerRemove(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: newBool(false), + PreserveOriginal: util.NewT(false), }, } a := ensureAnalyzer(ctx, db, def, t) diff --git a/test/collection_test.go b/test/collection_test.go index 683fc3dd..d84d8d93 100644 --- a/test/collection_test.go +++ b/test/collection_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2017-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2017-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -27,6 +27,8 @@ import ( "testing" "time" + "github.com/arangodb/go-driver/util" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -114,7 +116,7 @@ func TestCollection_CacheEnabled(t *testing.T) { t.Run("False", func(t *testing.T) { name := "test_create_collection_cache_false" _, err := db.CreateCollection(nil, name, &driver.CreateCollectionOptions{ - CacheEnabled: newBool(false), + CacheEnabled: util.NewT(false), }) require.NoError(t, err) @@ -131,7 +133,7 @@ func TestCollection_CacheEnabled(t *testing.T) { t.Run("True", func(t *testing.T) { name := "test_create_collection_cache_true" _, err := db.CreateCollection(nil, name, &driver.CreateCollectionOptions{ - CacheEnabled: newBool(true), + CacheEnabled: util.NewT(true), }) require.NoError(t, err) @@ -148,7 +150,7 @@ func TestCollection_CacheEnabled(t *testing.T) { t.Run("With update", func(t *testing.T) { name := "test_create_collection_cache_update" _, err := db.CreateCollection(nil, name, &driver.CreateCollectionOptions{ - CacheEnabled: newBool(false), + CacheEnabled: util.NewT(false), }) require.NoError(t, err) @@ -162,7 +164,7 @@ func TestCollection_CacheEnabled(t *testing.T) { require.False(t, prop.CacheEnabled) err = col.SetProperties(nil, driver.SetCollectionPropertiesOptions{ - CacheEnabled: newBool(true), + CacheEnabled: util.NewT(true), }) require.NoError(t, err) diff --git a/test/index_ensure_test.go b/test/index_ensure_test.go index 8d5edfc6..19f1ec18 100644 --- a/test/index_ensure_test.go +++ b/test/index_ensure_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2017-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2017-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ import ( "fmt" "testing" + "github.com/arangodb/go-driver/util" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -537,8 +539,8 @@ func TestEnsureInvertedIndex(t *testing.T) { Name: "inverted-opt", PrimarySort: driver.InvertedIndexPrimarySort{ Fields: []driver.ArangoSearchPrimarySortEntry{ - {Field: "test1", Ascending: newBool(true)}, - {Field: "test2", Ascending: newBool(false)}, + {Field: "test1", Ascending: util.NewT(true)}, + {Field: "test2", Ascending: util.NewT(false)}, }, Compression: driver.PrimarySortCompressionLz4, }, @@ -554,8 +556,8 @@ func TestEnsureInvertedIndex(t *testing.T) { Name: "inverted-opt-nested", PrimarySort: driver.InvertedIndexPrimarySort{ Fields: []driver.ArangoSearchPrimarySortEntry{ - {Field: "test1", Ascending: newBool(true)}, - {Field: "test2", Ascending: newBool(false)}, + {Field: "test1", Ascending: util.NewT(true)}, + {Field: "test2", Ascending: util.NewT(false)}, }, Compression: driver.PrimarySortCompressionLz4, }, @@ -588,7 +590,7 @@ func TestEnsureInvertedIndex(t *testing.T) { Name: "inverted-opt-optimize-top-k", PrimarySort: driver.InvertedIndexPrimarySort{ Fields: []driver.ArangoSearchPrimarySortEntry{ - {Field: "field1", Ascending: newBool(true)}, + {Field: "field1", Ascending: util.NewT(true)}, }, Compression: driver.PrimarySortCompressionLz4, }, diff --git a/test/view_alias_test.go b/test/view_alias_test.go index 028e6c63..6a172186 100644 --- a/test/view_alias_test.go +++ b/test/view_alias_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2020-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/util" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver" @@ -76,8 +78,8 @@ func TestSearchViewsAlias(t *testing.T) { Name: nameInvInd, PrimarySort: driver.InvertedIndexPrimarySort{ Fields: []driver.ArangoSearchPrimarySortEntry{ - {Field: "test1", Ascending: newBool(true)}, - {Field: "test2", Ascending: newBool(false)}, + {Field: "test1", Ascending: util.NewT(true)}, + {Field: "test2", Ascending: util.NewT(false)}, }, Compression: driver.PrimarySortCompressionLz4, }, diff --git a/test/view_test.go b/test/view_test.go index 64c86f73..d668cba1 100644 --- a/test/view_test.go +++ b/test/view_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2018-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2018-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -26,6 +26,8 @@ import ( "net/http" "testing" + "github.com/arangodb/go-driver/util" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -633,7 +635,7 @@ func TestUseArangoSearchViewWithPipelineAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(2), Max: newInt64(2), - PreserveOriginal: newBool(false), + PreserveOriginal: util.NewT(false), StreamType: newArangoSearchNGramStreamType(driver.ArangoSearchNGramStreamUTF8), }, }, @@ -923,10 +925,6 @@ func TestArangoSearchPrimarySort(t *testing.T) { } } -func newBool(v bool) *bool { - return &v -} - // TestArangoSearchViewProperties353 tests for custom analyzers. func TestArangoSearchViewProperties353(t *testing.T) { ctx := context.Background() @@ -955,8 +953,8 @@ func TestArangoSearchViewProperties353(t *testing.T) { }, }, }, - IncludeAllFields: newBool(true), - InBackground: newBool(false), + IncludeAllFields: util.NewT(true), + InBackground: util.NewT(false), }, }, } @@ -991,7 +989,7 @@ func TestArangoSearchViewProperties353(t *testing.T) { require.Contains(t, analyzer.Features, driver.ArangoSearchAnalyzerFeaturePosition) require.EqualValues(t, analyzer.Properties.Locale, "en_US") require.EqualValues(t, analyzer.Properties.Case, driver.ArangoSearchCaseLower) - require.Equal(t, newBool(true), link.IncludeAllFields) + require.Equal(t, util.NewT(true), link.IncludeAllFields) } func TestArangoSearchViewLinkAndStoredValueCache(t *testing.T) { @@ -1009,12 +1007,12 @@ func TestArangoSearchViewLinkAndStoredValueCache(t *testing.T) { StoredValues: []driver.StoredValue{ { Fields: []string{"f1", "f2"}, - Cache: newBool(true), + Cache: util.NewT(true), }, }, Links: driver.ArangoSearchLinks{ linkedColName: driver.ArangoSearchElementProperties{ - Cache: newBool(false), + Cache: util.NewT(false), }, }, } @@ -1025,12 +1023,12 @@ func TestArangoSearchViewLinkAndStoredValueCache(t *testing.T) { p, err := v.Properties(ctx) require.NoError(t, err) require.Len(t, p.StoredValues, 1) - require.Equal(t, newBool(true), p.StoredValues[0].Cache) + require.Equal(t, util.NewT(true), p.StoredValues[0].Cache) linkedColumnProps := p.Links[linkedColName] require.NotNil(t, linkedColumnProps) require.Nil(t, linkedColumnProps.Cache) // update props: set to cached - p.Links[linkedColName] = driver.ArangoSearchElementProperties{Cache: newBool(true)} + p.Links[linkedColName] = driver.ArangoSearchElementProperties{Cache: util.NewT(true)} err = v.SetProperties(ctx, p) require.NoError(t, err) @@ -1039,7 +1037,7 @@ func TestArangoSearchViewLinkAndStoredValueCache(t *testing.T) { require.NoError(t, err) linkedColumnProps = p.Links[linkedColName] require.NotNil(t, linkedColumnProps) - require.Equal(t, newBool(true), linkedColumnProps.Cache) + require.Equal(t, util.NewT(true), linkedColumnProps.Cache) } func TestArangoSearchViewInMemoryCache(t *testing.T) { @@ -1056,7 +1054,7 @@ func TestArangoSearchViewInMemoryCache(t *testing.T) { name := "test_create_asview" opts := &driver.ArangoSearchViewProperties{ - PrimarySortCache: newBool(true), + PrimarySortCache: util.NewT(true), } v, err := db.CreateArangoSearchView(ctx, name, opts) require.NoError(t, err) @@ -1066,7 +1064,7 @@ func TestArangoSearchViewInMemoryCache(t *testing.T) { // bug in arangod: the primarySortCache field is not returned in response. Fixed only in 3.9.6+: t.Run("must-be-returned-in-response", func(t *testing.T) { skipBelowVersion(c, "3.9.6", t) - require.Equal(t, newBool(true), p.PrimarySortCache) + require.Equal(t, util.NewT(true), p.PrimarySortCache) }) }) @@ -1077,13 +1075,13 @@ func TestArangoSearchViewInMemoryCache(t *testing.T) { name := "test_view_" opts := &driver.ArangoSearchViewProperties{ - PrimaryKeyCache: newBool(true), + PrimaryKeyCache: util.NewT(true), } v, err := db.CreateArangoSearchView(ctx, name, opts) require.NoError(t, err) p, err := v.Properties(ctx) require.NoError(t, err) - require.Equal(t, newBool(true), p.PrimaryKeyCache) + require.Equal(t, util.NewT(true), p.PrimaryKeyCache) }) } diff --git a/util/type.go b/util/type.go new file mode 100644 index 00000000..bdc6a58b --- /dev/null +++ b/util/type.go @@ -0,0 +1,25 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package util + +func NewT[T any](val T) *T { + return &val +} diff --git a/v2/CHANGELOG.md b/v2/CHANGELOG.md index 9b778469..47ad4cf5 100644 --- a/v2/CHANGELOG.md +++ b/v2/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log ## [master](https://github.com/arangodb/go-driver/tree/master) (N/A) +- Expose `NewT` method ## [2.1.1](https://github.com/arangodb/go-driver/tree/v2.1.1) (2024-09-27) - Improve backup tests stability diff --git a/v2/tests/admin_log_test.go b/v2/tests/admin_log_test.go index 83c2e5e0..6b974102 100644 --- a/v2/tests/admin_log_test.go +++ b/v2/tests/admin_log_test.go @@ -25,6 +25,8 @@ import ( "testing" "time" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -34,7 +36,7 @@ import ( func Test_LogLevels(t *testing.T) { // This test cannot run subtests parallel, because it changes admin settings. wrapOpts := WrapOptions{ - Parallel: newBool(false), + Parallel: utils.NewT(false), } Wrap(t, func(t *testing.T, client arangodb.Client) { @@ -70,7 +72,7 @@ func Test_LogLevelsForServers(t *testing.T) { // This test cannot run subtests parallel, because it changes admin settings. wrapOpts := WrapOptions{ - Parallel: newBool(false), + Parallel: utils.NewT(false), } Wrap(t, func(t *testing.T, client arangodb.Client) { diff --git a/v2/tests/admin_test.go b/v2/tests/admin_test.go index 2661cc94..cc9ca3e3 100644 --- a/v2/tests/admin_test.go +++ b/v2/tests/admin_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ import ( "testing" "time" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -32,7 +34,7 @@ import ( func Test_ServerMode(t *testing.T) { // This test can not run sub-tests parallelly, because it changes admin settings. wrapOpts := WrapOptions{ - Parallel: newBool(false), + Parallel: utils.NewT(false), } Wrap(t, func(t *testing.T, client arangodb.Client) { @@ -77,7 +79,7 @@ func Test_Version(t *testing.T) { Wrap(t, func(t *testing.T, client arangodb.Client) { withContextT(t, time.Minute, func(ctx context.Context, t testing.TB) { v, err := client.VersionWithOptions(context.Background(), &arangodb.GetVersionOptions{ - Details: newBool(true), + Details: utils.NewT(true), }) require.NoError(t, err) require.NotEmpty(t, v.Version) diff --git a/v2/tests/asyncjob_test.go b/v2/tests/asyncjob_test.go index 7f4b0328..60e27046 100644 --- a/v2/tests/asyncjob_test.go +++ b/v2/tests/asyncjob_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -26,6 +26,8 @@ import ( "testing" "time" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -33,8 +35,8 @@ import ( ) var asyncTestOpt = WrapOptions{ - Async: newBool(true), - Parallel: newBool(false), + Async: utils.NewT(true), + Parallel: utils.NewT(false), } func TestAsyncJobListDone(t *testing.T) { diff --git a/v2/tests/backup_test.go b/v2/tests/backup_test.go index b32e6589..4a4b27cb 100644 --- a/v2/tests/backup_test.go +++ b/v2/tests/backup_test.go @@ -29,6 +29,8 @@ import ( "testing" "time" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -86,7 +88,7 @@ func Test_CreateBackupSimple(t *testing.T) { require.NoError(t, err, "DeleteBackup failed") }) }, WrapOptions{ - Parallel: newBool(false), + Parallel: utils.NewT(false), }) } @@ -140,7 +142,7 @@ func Test_RestoreBackupSimple(t *testing.T) { }) }) }, WrapOptions{ - Parallel: newBool(false), + Parallel: utils.NewT(false), }) } @@ -225,7 +227,7 @@ func Test_BackupFullFlow(t *testing.T) { waitForSync(t, ctx, client) }) }, WrapOptions{ - Parallel: newBool(false), + Parallel: utils.NewT(false), }) } @@ -261,7 +263,7 @@ func Test_UploadBackupFailAndAbort(t *testing.T) { }) }) }, WrapOptions{ - Parallel: newBool(false), + Parallel: utils.NewT(false), }) } diff --git a/v2/tests/database_analyzer_test.go b/v2/tests/database_analyzer_test.go index df0ae026..c62b4325 100644 --- a/v2/tests/database_analyzer_test.go +++ b/v2/tests/database_analyzer_test.go @@ -24,6 +24,8 @@ import ( "encoding/json" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -95,23 +97,23 @@ func Test_Analyzers(t *testing.T) { Name: "my-ngram", Type: arangodb.ArangoSearchAnalyzerTypeNGram, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Min: newT[int64](1), - Max: newT[int64](14), - PreserveOriginal: newBool(false), + Min: utils.NewT[int64](1), + Max: utils.NewT[int64](14), + PreserveOriginal: utils.NewT(false), }, }, ExpectedDefinition: &arangodb.AnalyzerDefinition{ Name: "my-ngram", Type: arangodb.ArangoSearchAnalyzerTypeNGram, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Min: newT[int64](1), - Max: newT[int64](14), - PreserveOriginal: newBool(false), + Min: utils.NewT[int64](1), + Max: utils.NewT[int64](14), + PreserveOriginal: utils.NewT(false), // Check defaults for 3.6 - StartMarker: newT(""), - EndMarker: newT(""), - StreamType: newT(arangodb.ArangoSearchNGramStreamBinary), + StartMarker: utils.NewT(""), + EndMarker: utils.NewT(""), + StreamType: utils.NewT(arangodb.ArangoSearchNGramStreamBinary), }, }, }, @@ -122,12 +124,12 @@ func Test_Analyzers(t *testing.T) { Name: "my-ngram-custom", Type: arangodb.ArangoSearchAnalyzerTypeNGram, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Min: newT[int64](1), - Max: newT[int64](14), - PreserveOriginal: newBool(false), - StartMarker: newT("^"), - EndMarker: newT("^"), - StreamType: newT(arangodb.ArangoSearchNGramStreamUTF8), + Min: utils.NewT[int64](1), + Max: utils.NewT[int64](14), + PreserveOriginal: utils.NewT(false), + StartMarker: utils.NewT("^"), + EndMarker: utils.NewT("^"), + StreamType: utils.NewT(arangodb.ArangoSearchNGramStreamUTF8), }, }, }, @@ -142,12 +144,12 @@ func Test_Analyzers(t *testing.T) { { Type: arangodb.ArangoSearchAnalyzerTypeNGram, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Min: newT[int64](1), - Max: newT[int64](14), - PreserveOriginal: newBool(false), - StartMarker: newT("^"), - EndMarker: newT("^"), - StreamType: newT(arangodb.ArangoSearchNGramStreamUTF8), + Min: utils.NewT[int64](1), + Max: utils.NewT[int64](14), + PreserveOriginal: utils.NewT(false), + StartMarker: utils.NewT("^"), + EndMarker: utils.NewT("^"), + StreamType: utils.NewT(arangodb.ArangoSearchNGramStreamUTF8), }, }, }, @@ -162,11 +164,11 @@ func Test_Analyzers(t *testing.T) { Type: arangodb.ArangoSearchAnalyzerTypeAQL, Properties: arangodb.ArangoSearchAnalyzerProperties{ QueryString: `FOR year IN [ 2011, 2012, 2013 ] FOR quarter IN [ 1, 2, 3, 4 ] RETURN { year, quarter, formatted: CONCAT(quarter, " / ", year)}`, - CollapsePositions: newBool(true), - KeepNull: newBool(false), - BatchSize: newT(10), + CollapsePositions: utils.NewT(true), + KeepNull: utils.NewT(false), + BatchSize: utils.NewT(10), ReturnType: arangodb.ArangoSearchAnalyzerAQLReturnTypeString.New(), - MemoryLimit: newT(1024 * 1024), + MemoryLimit: utils.NewT(1024 * 1024), }, }, }, @@ -178,9 +180,9 @@ func Test_Analyzers(t *testing.T) { Type: arangodb.ArangoSearchAnalyzerTypeGeoPoint, Properties: arangodb.ArangoSearchAnalyzerProperties{ Options: &arangodb.ArangoSearchAnalyzerGeoOptions{ - MaxCells: newT(20), - MinLevel: newT(4), - MaxLevel: newT(23), + MaxCells: utils.NewT(20), + MinLevel: utils.NewT(4), + MaxLevel: utils.NewT(23), }, Latitude: []string{}, Longitude: []string{}, @@ -195,9 +197,9 @@ func Test_Analyzers(t *testing.T) { Type: arangodb.ArangoSearchAnalyzerTypeGeoJSON, Properties: arangodb.ArangoSearchAnalyzerProperties{ Options: &arangodb.ArangoSearchAnalyzerGeoOptions{ - MaxCells: newT(20), - MinLevel: newT(4), - MaxLevel: newT(23), + MaxCells: utils.NewT(20), + MinLevel: utils.NewT(4), + MaxLevel: utils.NewT(23), }, Type: arangodb.ArangoSearchAnalyzerGeoJSONTypeShape.New(), }, @@ -210,11 +212,11 @@ func Test_Analyzers(t *testing.T) { Name: "my-geo_s2", Type: arangodb.ArangoSearchAnalyzerTypeGeoS2, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Format: newT(arangodb.ArangoSearchFormatLatLngInt), + Format: utils.NewT(arangodb.ArangoSearchFormatLatLngInt), Options: &arangodb.ArangoSearchAnalyzerGeoOptions{ - MaxCells: newT(20), - MinLevel: newT(4), - MaxLevel: newT(23), + MaxCells: utils.NewT(20), + MinLevel: utils.NewT(4), + MaxLevel: utils.NewT(23), }, Type: arangodb.ArangoSearchAnalyzerGeoJSONTypeShape.New(), }, @@ -223,11 +225,11 @@ func Test_Analyzers(t *testing.T) { Name: "my-geo_s2", Type: arangodb.ArangoSearchAnalyzerTypeGeoS2, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Format: newT(arangodb.ArangoSearchFormatLatLngInt), + Format: utils.NewT(arangodb.ArangoSearchFormatLatLngInt), Options: &arangodb.ArangoSearchAnalyzerGeoOptions{ - MaxCells: newT(20), - MinLevel: newT(4), - MaxLevel: newT(23), + MaxCells: utils.NewT(20), + MinLevel: utils.NewT(4), + MaxLevel: utils.NewT(23), }, Type: arangodb.ArangoSearchAnalyzerGeoJSONTypeShape.New(), }, @@ -271,7 +273,7 @@ func Test_Analyzers(t *testing.T) { Name: "my-stopWords", Type: arangodb.ArangoSearchAnalyzerTypeStopwords, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Hex: newBool(true), + Hex: utils.NewT(true), Stopwords: []string{ "616e64", "746865", @@ -282,7 +284,7 @@ func Test_Analyzers(t *testing.T) { Name: "my-stopWords", Type: arangodb.ArangoSearchAnalyzerTypeStopwords, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Hex: newBool(true), + Hex: utils.NewT(true), Stopwords: []string{ "616e64", "746865", @@ -301,14 +303,14 @@ func Test_Analyzers(t *testing.T) { Analyzer: &arangodb.AnalyzerDefinition{ Type: arangodb.ArangoSearchAnalyzerTypeStopwords, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Hex: newBool(true), + Hex: utils.NewT(true), Stopwords: []string{ "616e64", "746865", }, }, }, - NumHashes: newT[uint64](2), + NumHashes: utils.NewT[uint64](2), }, }, ExpectedDefinition: &arangodb.AnalyzerDefinition{ @@ -318,14 +320,14 @@ func Test_Analyzers(t *testing.T) { Analyzer: &arangodb.AnalyzerDefinition{ Type: arangodb.ArangoSearchAnalyzerTypeStopwords, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Hex: newBool(true), + Hex: utils.NewT(true), Stopwords: []string{ "616e64", "746865", }, }, }, - NumHashes: newT[uint64](2), + NumHashes: utils.NewT[uint64](2), }, }, }, diff --git a/v2/tests/database_collection_doc_create_test.go b/v2/tests/database_collection_doc_create_test.go index 76c735ea..d3b0f462 100644 --- a/v2/tests/database_collection_doc_create_test.go +++ b/v2/tests/database_collection_doc_create_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -111,7 +113,7 @@ func Test_DatabaseCollectionDocCreateOverwrite(t *testing.T) { metaReplacedSimple, err := col.CreateDocumentWithOptions(ctx, docOverwrite, &arangodb.CollectionDocumentCreateOptions{ OldObject: &oldDoc, NewObject: &newDoc, - Overwrite: newBool(true), + Overwrite: utils.NewT(true), }) require.NoError(t, err) require.NotEqual(t, metaReplacedSimple.Rev, metaReplaced.Rev) @@ -132,7 +134,7 @@ func Test_DatabaseCollectionDocCreateKeepNull(t *testing.T) { doc := DocWithRev{ Name: "test-keep-null", - Age: newInt(10), + Age: utils.NewT(10), } meta, err := col.CreateDocument(ctx, doc) @@ -148,7 +150,7 @@ func Test_DatabaseCollectionDocCreateKeepNull(t *testing.T) { overwriteMode := arangodb.CollectionDocumentCreateOverwriteModeUpdate metaUpdated, err := col.CreateDocumentWithOptions(ctx, docOverwrite, &arangodb.CollectionDocumentCreateOptions{ - KeepNull: newBool(true), + KeepNull: utils.NewT(true), OverwriteMode: overwriteMode.New(), }) require.NoError(t, err) @@ -174,7 +176,7 @@ func Test_DatabaseCollectionDocCreateKeepNull(t *testing.T) { overwriteMode := arangodb.CollectionDocumentCreateOverwriteModeUpdate metaUpdated, err := col.CreateDocumentWithOptions(ctx, docOverwrite, &arangodb.CollectionDocumentCreateOptions{ - KeepNull: newBool(false), + KeepNull: utils.NewT(false), OverwriteMode: overwriteMode.New(), }) require.NoError(t, err) @@ -223,7 +225,7 @@ func Test_DatabaseCollectionDocCreateMergeObjects(t *testing.T) { overwriteMode := arangodb.CollectionDocumentCreateOverwriteModeUpdate metaUpdated, err := col.CreateDocumentWithOptions(ctx, docOverwrite, &arangodb.CollectionDocumentCreateOptions{ - MergeObjects: newBool(true), + MergeObjects: utils.NewT(true), OverwriteMode: overwriteMode.New(), }) require.NoError(t, err) @@ -253,7 +255,7 @@ func Test_DatabaseCollectionDocCreateMergeObjects(t *testing.T) { overwriteMode := arangodb.CollectionDocumentCreateOverwriteModeUpdate metaUpdated, err := col.CreateDocumentWithOptions(ctx, docOverwrite, &arangodb.CollectionDocumentCreateOptions{ - MergeObjects: newBool(false), + MergeObjects: utils.NewT(false), OverwriteMode: overwriteMode.New(), }) require.NoError(t, err) @@ -285,11 +287,11 @@ func Test_DatabaseCollectionDocCreateSilent(t *testing.T) { doc := DocWithRev{ Name: "test-silent", - Age: newInt(42), + Age: utils.NewT(42), } meta, err := col.CreateDocumentWithOptions(ctx, doc, &arangodb.CollectionDocumentCreateOptions{ - Silent: newBool(true), + Silent: utils.NewT(true), }) require.NoError(t, err) require.Empty(t, meta.Key, "response should be empty (silent)!") @@ -306,12 +308,12 @@ func Test_DatabaseCollectionDocCreateWaitForSync(t *testing.T) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { doc := DocWithRev{ Name: "test-wait-for-sync", - Age: newInt(23), + Age: utils.NewT(23), } t.Run("WithWaitForSync==false should not return an error", func(t *testing.T) { meta, err := col.CreateDocumentWithOptions(ctx, doc, &arangodb.CollectionDocumentCreateOptions{ - WithWaitForSync: newBool(false), + WithWaitForSync: utils.NewT(false), }) require.NoError(t, err) require.NotEmpty(t, meta.Key) @@ -319,7 +321,7 @@ func Test_DatabaseCollectionDocCreateWaitForSync(t *testing.T) { t.Run("WithWaitForSync==true should not return an error", func(t *testing.T) { meta, err := col.CreateDocumentWithOptions(ctx, doc, &arangodb.CollectionDocumentCreateOptions{ - WithWaitForSync: newBool(true), + WithWaitForSync: utils.NewT(true), }) require.NoError(t, err) require.NotEmpty(t, meta.Key) @@ -339,7 +341,7 @@ func Test_DatabaseCollectionDocCreateReplaceWithVersionAttribute(t *testing.T) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { doc := DocWithRev{ Name: "test-version-attribute", - Age: newInt(23), + Age: utils.NewT(23), } meta, err := col.CreateDocument(ctx, doc) @@ -351,14 +353,14 @@ func Test_DatabaseCollectionDocCreateReplaceWithVersionAttribute(t *testing.T) { docReplaced := DocWithRev{ Name: "test-check-Replaced", - Age: newInt(19), + Age: utils.NewT(19), Key: meta.Key, } metaDoc, err := col.CreateDocumentWithOptions(ctx, docReplaced, &arangodb.CollectionDocumentCreateOptions{ NewObject: &newDoc, OldObject: &oldDoc, - Overwrite: newBool(true), + Overwrite: utils.NewT(true), VersionAttribute: "age", }) require.NoError(t, err) @@ -375,14 +377,14 @@ func Test_DatabaseCollectionDocCreateReplaceWithVersionAttribute(t *testing.T) { docReplaced := DocWithRev{ Name: "test-check-Replaced", - Age: newInt(99), + Age: utils.NewT(99), Key: meta.Key, } metaDoc, err := col.CreateDocumentWithOptions(ctx, docReplaced, &arangodb.CollectionDocumentCreateOptions{ NewObject: &newDoc, OldObject: &oldDoc, - Overwrite: newBool(true), + Overwrite: utils.NewT(true), VersionAttribute: "age", }) require.NoError(t, err) diff --git a/v2/tests/database_collection_doc_delete_test.go b/v2/tests/database_collection_doc_delete_test.go index 7ae52ea7..a031298a 100644 --- a/v2/tests/database_collection_doc_delete_test.go +++ b/v2/tests/database_collection_doc_delete_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -221,7 +223,7 @@ func Test_DatabaseCollectionDocDeleteIgnoreRevs(t *testing.T) { } delReader, err := col.DeleteDocumentsWithOptions(ctx, docToRemove, &arangodb.CollectionDocumentDeleteOptions{ - IgnoreRevs: newBool(false), + IgnoreRevs: utils.NewT(false), }) require.NoError(t, err) @@ -243,7 +245,7 @@ func Test_DatabaseCollectionDocDeleteIgnoreRevs(t *testing.T) { } delReader, err := col.DeleteDocumentsWithOptions(ctx, docToRemove, &arangodb.CollectionDocumentDeleteOptions{ - IgnoreRevs: newBool(false), + IgnoreRevs: utils.NewT(false), }) require.NoError(t, err) @@ -266,7 +268,7 @@ func Test_DatabaseCollectionDocDeleteIgnoreRevs(t *testing.T) { } delReader, err := col.DeleteDocumentsWithOptions(ctx, docToRemove, &arangodb.CollectionDocumentDeleteOptions{ - IgnoreRevs: newBool(false), + IgnoreRevs: utils.NewT(false), }) require.NoError(t, err) @@ -296,13 +298,13 @@ func Test_DatabaseCollectionDocDeleteSilent(t *testing.T) { doc := DocWithRev{ Name: "test-silent", - Age: newInt(42), + Age: utils.NewT(42), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) metaDeleted, err := col.DeleteDocumentWithOptions(ctx, meta.Key, &arangodb.CollectionDocumentDeleteOptions{ - Silent: newBool(true), + Silent: utils.NewT(true), }) require.NoError(t, err) require.Empty(t, metaDeleted.Key, "response should be empty (silent)!") @@ -320,13 +322,13 @@ func Test_DatabaseCollectionDocDeleteWaitForSync(t *testing.T) { t.Run("WithWaitForSync==false should not return an error", func(t *testing.T) { doc := DocWithRev{ Name: "test-wait-for-sync-false", - Age: newInt(23), + Age: utils.NewT(23), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) metaDel, err := col.DeleteDocumentWithOptions(ctx, meta.Key, &arangodb.CollectionDocumentDeleteOptions{ - WithWaitForSync: newBool(false), + WithWaitForSync: utils.NewT(false), }) require.NoError(t, err) require.NotEmpty(t, metaDel.Key) @@ -335,13 +337,13 @@ func Test_DatabaseCollectionDocDeleteWaitForSync(t *testing.T) { t.Run("WithWaitForSync==true should not return an error", func(t *testing.T) { doc := DocWithRev{ Name: "test-wait-for-sync-true", - Age: newInt(23), + Age: utils.NewT(23), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) metaDel, err := col.DeleteDocumentWithOptions(ctx, meta.Key, &arangodb.CollectionDocumentDeleteOptions{ - WithWaitForSync: newBool(true), + WithWaitForSync: utils.NewT(true), }) require.NoError(t, err) require.NotEmpty(t, metaDel.Key) diff --git a/v2/tests/database_collection_doc_read_test.go b/v2/tests/database_collection_doc_read_test.go index 88461ad0..8ef82bde 100644 --- a/v2/tests/database_collection_doc_read_test.go +++ b/v2/tests/database_collection_doc_read_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -107,7 +109,7 @@ func Test_DatabaseCollectionDocReadIgnoreRevs(t *testing.T) { } r, err := col.ReadDocumentsWithOptions(ctx, &docToRead, &arangodb.CollectionDocumentReadOptions{ - IgnoreRevs: newBool(false), + IgnoreRevs: utils.NewT(false), }) require.NoError(t, err) @@ -127,7 +129,7 @@ func Test_DatabaseCollectionDocReadIgnoreRevs(t *testing.T) { } r, err := col.ReadDocumentsWithOptions(ctx, &docToRead, &arangodb.CollectionDocumentReadOptions{ - IgnoreRevs: newBool(false), + IgnoreRevs: utils.NewT(false), }) require.NoError(t, err) @@ -144,7 +146,7 @@ func Test_DatabaseCollectionDocReadIgnoreRevs(t *testing.T) { } r, err := col.ReadDocumentsWithOptions(ctx, &docToRead, &arangodb.CollectionDocumentReadOptions{ - IgnoreRevs: newBool(false), + IgnoreRevs: utils.NewT(false), }) require.NoError(t, err) @@ -166,7 +168,7 @@ func Test_DatabaseCollectionDocReadAllowDirtyReads(t *testing.T) { t.Run("WithWaitForSync==false should not return an error", func(t *testing.T) { doc := DocWithRev{ Name: "test-wait-for-sync-false", - Age: newInt(23), + Age: utils.NewT(23), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) diff --git a/v2/tests/database_collection_doc_replace_test.go b/v2/tests/database_collection_doc_replace_test.go index b70bb3c7..e653c92c 100644 --- a/v2/tests/database_collection_doc_replace_test.go +++ b/v2/tests/database_collection_doc_replace_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -93,7 +95,7 @@ func Test_DatabaseCollectionDocReplaceIgnoreRevs(t *testing.T) { t.Run("do not replace if rev doesn't match", func(t *testing.T) { docReplace.Rev = "wrong-rev" metaError, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, docReplace, &arangodb.CollectionDocumentReplaceOptions{ - IgnoreRevs: newBool(false), + IgnoreRevs: utils.NewT(false), }) require.Error(t, err) require.Empty(t, metaError.Rev) @@ -102,7 +104,7 @@ func Test_DatabaseCollectionDocReplaceIgnoreRevs(t *testing.T) { t.Run("do an update if rev match", func(t *testing.T) { docReplace.Rev = meta.Rev metaReplaced, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, docReplace, &arangodb.CollectionDocumentReplaceOptions{ - IgnoreRevs: newBool(false), + IgnoreRevs: utils.NewT(false), }) require.NoError(t, err) require.NotEmpty(t, metaReplaced.Rev) @@ -112,7 +114,7 @@ func Test_DatabaseCollectionDocReplaceIgnoreRevs(t *testing.T) { t.Run("do an update if rev is missing", func(t *testing.T) { docReplace.Rev = "" metaReplaced, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, docReplace, &arangodb.CollectionDocumentReplaceOptions{ - IgnoreRevs: newBool(false), + IgnoreRevs: utils.NewT(false), }) require.NoError(t, err) require.NotEmpty(t, metaReplaced.Rev) @@ -133,7 +135,7 @@ func Test_DatabaseCollectionDocReplaceSilent(t *testing.T) { doc := DocWithRev{ Name: "test-silent", - Age: newInt(42), + Age: utils.NewT(42), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) @@ -142,7 +144,7 @@ func Test_DatabaseCollectionDocReplaceSilent(t *testing.T) { Name: "test-silent-updated", } metaUpdated, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, docReplace, &arangodb.CollectionDocumentReplaceOptions{ - Silent: newBool(true), + Silent: utils.NewT(true), }) require.NoError(t, err) require.Empty(t, metaUpdated.Key, "response should be empty (silent)!") @@ -159,24 +161,24 @@ func Test_DatabaseCollectionDocReplaceWaitForSync(t *testing.T) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { doc := DocWithRev{ Name: "test-wait-for-sync", - Age: newInt(23), + Age: utils.NewT(23), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) t.Run("WithWaitForSync==false should not return an error", func(t *testing.T) { - doc.Age = newInt(42) + doc.Age = utils.NewT(42) meta, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, doc, &arangodb.CollectionDocumentReplaceOptions{ - WithWaitForSync: newBool(false), + WithWaitForSync: utils.NewT(false), }) require.NoError(t, err) require.NotEmpty(t, meta.Key) }) t.Run("WithWaitForSync==true should not return an error", func(t *testing.T) { - doc.Age = newInt(32) + doc.Age = utils.NewT(32) meta, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, doc, &arangodb.CollectionDocumentReplaceOptions{ - WithWaitForSync: newBool(true), + WithWaitForSync: utils.NewT(true), }) require.NoError(t, err) require.NotEmpty(t, meta.Key) @@ -196,7 +198,7 @@ func Test_DatabaseCollectionDocReplaceVersionAttribute(t *testing.T) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { doc := DocWithRev{ Name: "test-version-attribute", - Age: newInt(23), + Age: utils.NewT(23), } meta, err := col.CreateDocument(ctx, doc) @@ -208,7 +210,7 @@ func Test_DatabaseCollectionDocReplaceVersionAttribute(t *testing.T) { docReplaced := DocWithRev{ Name: "test-check-Replaced", - Age: newInt(19), + Age: utils.NewT(19), } metaDoc, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, docReplaced, &arangodb.CollectionDocumentReplaceOptions{ @@ -230,7 +232,7 @@ func Test_DatabaseCollectionDocReplaceVersionAttribute(t *testing.T) { docReplaced := DocWithRev{ Name: "test-check-Replaced", - Age: newInt(99), + Age: utils.NewT(99), } metaDoc, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, docReplaced, &arangodb.CollectionDocumentReplaceOptions{ diff --git a/v2/tests/database_collection_doc_update_test.go b/v2/tests/database_collection_doc_update_test.go index 2f7ac76a..dce447b0 100644 --- a/v2/tests/database_collection_doc_update_test.go +++ b/v2/tests/database_collection_doc_update_test.go @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -93,7 +95,7 @@ func Test_DatabaseCollectionDocUpdateIgnoreRevs(t *testing.T) { t.Run("do not update if rev doesn't match", func(t *testing.T) { docUpdate.Rev = "wrong-rev" metaError, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docUpdate, &arangodb.CollectionDocumentUpdateOptions{ - IgnoreRevs: newBool(false), + IgnoreRevs: utils.NewT(false), }) require.Error(t, err) require.Empty(t, metaError.Rev) @@ -102,7 +104,7 @@ func Test_DatabaseCollectionDocUpdateIgnoreRevs(t *testing.T) { t.Run("do an update if rev match", func(t *testing.T) { docUpdate.Rev = meta.Rev metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docUpdate, &arangodb.CollectionDocumentUpdateOptions{ - IgnoreRevs: newBool(false), + IgnoreRevs: utils.NewT(false), }) require.NoError(t, err) require.NotEmpty(t, metaUpdated.Rev) @@ -112,7 +114,7 @@ func Test_DatabaseCollectionDocUpdateIgnoreRevs(t *testing.T) { t.Run("do an update if rev is missing", func(t *testing.T) { docUpdate.Rev = "" metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docUpdate, &arangodb.CollectionDocumentUpdateOptions{ - IgnoreRevs: newBool(false), + IgnoreRevs: utils.NewT(false), }) require.NoError(t, err) require.NotEmpty(t, metaUpdated.Rev) @@ -132,7 +134,7 @@ func Test_DatabaseCollectionDocUpdateKeepNull(t *testing.T) { doc := DocWithRev{ Name: "test-keep-null", - Age: newInt(10), + Age: utils.NewT(10), } meta, err := col.CreateDocument(ctx, doc) @@ -147,7 +149,7 @@ func Test_DatabaseCollectionDocUpdateKeepNull(t *testing.T) { } metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docOverwrite, &arangodb.CollectionDocumentUpdateOptions{ - KeepNull: newBool(true), + KeepNull: utils.NewT(true), }) require.NoError(t, err) require.Equal(t, metaUpdated.Key, meta.Key) @@ -171,7 +173,7 @@ func Test_DatabaseCollectionDocUpdateKeepNull(t *testing.T) { } metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docOverwrite, &arangodb.CollectionDocumentUpdateOptions{ - KeepNull: newBool(false), + KeepNull: utils.NewT(false), }) require.NoError(t, err) require.Equal(t, metaUpdated.Key, meta.Key) @@ -218,7 +220,7 @@ func Test_DatabaseCollectionDocUpdateMergeObjects(t *testing.T) { } metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docOverwrite, &arangodb.CollectionDocumentUpdateOptions{ - MergeObjects: newBool(true), + MergeObjects: utils.NewT(true), }) require.NoError(t, err) require.Equal(t, metaUpdated.Key, meta.Key) @@ -246,7 +248,7 @@ func Test_DatabaseCollectionDocUpdateMergeObjects(t *testing.T) { } metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docOverwrite, &arangodb.CollectionDocumentUpdateOptions{ - MergeObjects: newBool(false), + MergeObjects: utils.NewT(false), }) require.NoError(t, err) require.Equal(t, metaUpdated.Key, meta.Key) @@ -277,7 +279,7 @@ func Test_DatabaseCollectionDocUpdateSilent(t *testing.T) { doc := DocWithRev{ Name: "test-silent", - Age: newInt(42), + Age: utils.NewT(42), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) @@ -286,7 +288,7 @@ func Test_DatabaseCollectionDocUpdateSilent(t *testing.T) { Name: "test-silent-updated", } metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docUpdate, &arangodb.CollectionDocumentUpdateOptions{ - Silent: newBool(true), + Silent: utils.NewT(true), }) require.NoError(t, err) require.Empty(t, metaUpdated.Key, "response should be empty (silent)!") @@ -303,24 +305,24 @@ func Test_DatabaseCollectionDocUpdateWaitForSync(t *testing.T) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { doc := DocWithRev{ Name: "test-wait-for-sync", - Age: newInt(23), + Age: utils.NewT(23), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) t.Run("WithWaitForSync==false should not return an error", func(t *testing.T) { - doc.Age = newInt(42) + doc.Age = utils.NewT(42) meta, err := col.UpdateDocumentWithOptions(ctx, meta.Key, doc, &arangodb.CollectionDocumentUpdateOptions{ - WithWaitForSync: newBool(false), + WithWaitForSync: utils.NewT(false), }) require.NoError(t, err) require.NotEmpty(t, meta.Key) }) t.Run("WithWaitForSync==true should not return an error", func(t *testing.T) { - doc.Age = newInt(32) + doc.Age = utils.NewT(32) meta, err := col.UpdateDocumentWithOptions(ctx, meta.Key, doc, &arangodb.CollectionDocumentUpdateOptions{ - WithWaitForSync: newBool(true), + WithWaitForSync: utils.NewT(true), }) require.NoError(t, err) require.NotEmpty(t, meta.Key) @@ -340,7 +342,7 @@ func Test_DatabaseCollectionDocUpdateVersionAttribute(t *testing.T) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { doc := DocWithRev{ Name: "test-version-attribute", - Age: newInt(23), + Age: utils.NewT(23), } meta, err := col.CreateDocument(ctx, doc) @@ -352,7 +354,7 @@ func Test_DatabaseCollectionDocUpdateVersionAttribute(t *testing.T) { docUpdate := DocWithRev{ Name: "test-check-UPDATED", - Age: newInt(19), + Age: utils.NewT(19), } metaDoc, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docUpdate, &arangodb.CollectionDocumentUpdateOptions{ @@ -374,7 +376,7 @@ func Test_DatabaseCollectionDocUpdateVersionAttribute(t *testing.T) { docUpdate := DocWithRev{ Name: "test-check-UPDATED", - Age: newInt(99), + Age: utils.NewT(99), } metaDoc, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docUpdate, &arangodb.CollectionDocumentUpdateOptions{ diff --git a/v2/tests/database_collection_indexes_test.go b/v2/tests/database_collection_indexes_test.go index fc830651..149f2f1c 100644 --- a/v2/tests/database_collection_indexes_test.go +++ b/v2/tests/database_collection_indexes_test.go @@ -26,6 +26,8 @@ import ( "testing" "time" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/exp/slices" @@ -88,23 +90,23 @@ func Test_EnsurePersistentIndex(t *testing.T) { {true, 2, []string{"age", "name"}, nil}, // same as default {false, 2, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: newBool(false), Sparse: newBool(false)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(false), Sparse: utils.NewT(false)}}, // unique {true, 3, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: newBool(true), Sparse: newBool(false)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(true), Sparse: utils.NewT(false)}}, {false, 3, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: newBool(true), Sparse: newBool(false)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(true), Sparse: utils.NewT(false)}}, {true, 4, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: newBool(true), Sparse: newBool(true)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(true), Sparse: utils.NewT(true)}}, {false, 4, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: newBool(true), Sparse: newBool(true)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(true), Sparse: utils.NewT(true)}}, {true, 5, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: newBool(false), Sparse: newBool(true)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(false), Sparse: utils.NewT(true)}}, {false, 5, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: newBool(false), Sparse: newBool(true)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(false), Sparse: utils.NewT(true)}}, } for _, testOpt := range testOptions { @@ -138,7 +140,7 @@ func Test_EnsurePersistentIndex(t *testing.T) { options := &arangodb.CreatePersistentIndexOptions{ StoredValues: storedValues, - CacheEnabled: newBool(true), + CacheEnabled: utils.NewT(true), } idx, created, err := col.EnsurePersistentIndex(ctx, fields, options) @@ -169,9 +171,9 @@ func Test_EnsurePersistentIndexDeduplicate(t *testing.T) { t.Run("Create index with Deduplicate OFF", func(t *testing.T) { idx, created, err := col.EnsurePersistentIndex(ctx, []string{"tags[*]"}, &arangodb.CreatePersistentIndexOptions{ - Deduplicate: newBool(false), - Unique: newBool(true), - Sparse: newBool(false), + Deduplicate: utils.NewT(false), + Unique: utils.NewT(true), + Sparse: utils.NewT(false), }) require.NoError(t, err) require.True(t, created) @@ -188,9 +190,9 @@ func Test_EnsurePersistentIndexDeduplicate(t *testing.T) { t.Run("Create index with Deduplicate ON", func(t *testing.T) { idx, created, err := col.EnsurePersistentIndex(ctx, []string{"tags[*]"}, &arangodb.CreatePersistentIndexOptions{ - Deduplicate: newBool(true), - Unique: newBool(true), - Sparse: newBool(false), + Deduplicate: utils.NewT(true), + Unique: utils.NewT(true), + Sparse: utils.NewT(false), }) require.NoError(t, err) require.True(t, created) @@ -299,8 +301,8 @@ func Test_EnsureGeoIndexIndex(t *testing.T) { t.Run("Test GeoJSON opts", func(t *testing.T) { var testOptions = []arangodb.CreateGeoIndexOptions{ - {GeoJSON: newBool(true)}, - {GeoJSON: newBool(false)}, + {GeoJSON: utils.NewT(true)}, + {GeoJSON: utils.NewT(false)}, } for _, testOpt := range testOptions { idx, created, err := col.EnsureGeoIndex(ctx, []string{"geo"}, &testOpt) @@ -323,25 +325,25 @@ func Test_EnsureGeoIndexIndex(t *testing.T) { true, false, []string{"geoOld1"}, - &arangodb.CreateGeoIndexOptions{LegacyPolygons: newBool(true)}, + &arangodb.CreateGeoIndexOptions{LegacyPolygons: utils.NewT(true)}, }, { false, false, []string{"geoOld2"}, - &arangodb.CreateGeoIndexOptions{LegacyPolygons: newBool(false)}, + &arangodb.CreateGeoIndexOptions{LegacyPolygons: utils.NewT(false)}, }, { false, true, []string{"geoOld3"}, - &arangodb.CreateGeoIndexOptions{GeoJSON: newBool(true), LegacyPolygons: newBool(false)}, + &arangodb.CreateGeoIndexOptions{GeoJSON: utils.NewT(true), LegacyPolygons: utils.NewT(false)}, }, { false, false, []string{"geoOld4"}, - &arangodb.CreateGeoIndexOptions{GeoJSON: newBool(false), LegacyPolygons: newBool(false)}, + &arangodb.CreateGeoIndexOptions{GeoJSON: utils.NewT(false), LegacyPolygons: utils.NewT(false)}, }, } diff --git a/v2/tests/database_collection_operations_test.go b/v2/tests/database_collection_operations_test.go index ea85ac56..2ca627fe 100644 --- a/v2/tests/database_collection_operations_test.go +++ b/v2/tests/database_collection_operations_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -26,6 +26,8 @@ import ( "testing" "time" + "github.com/arangodb/go-driver/v2/utils" + "github.com/arangodb/go-driver/v2/arangodb" "github.com/arangodb/go-driver/v2/arangodb/shared" "github.com/stretchr/testify/assert" @@ -113,7 +115,7 @@ func Test_CollectionSetProperties(t *testing.T) { ReplicationFactor: 2, JournalSize: 1048576 * 2, NumberOfShards: 2, - CacheEnabled: newBool(false), + CacheEnabled: utils.NewT(false), } Wrap(t, func(t *testing.T, client arangodb.Client) { @@ -133,10 +135,10 @@ func Test_CollectionSetProperties(t *testing.T) { }) newProps := arangodb.SetCollectionPropertiesOptions{ - WaitForSync: newBool(true), + WaitForSync: utils.NewT(true), ReplicationFactor: 3, WriteConcern: 2, - CacheEnabled: newBool(true), + CacheEnabled: utils.NewT(true), Schema: nil, } err = col.SetProperties(ctx, newProps) @@ -200,7 +202,7 @@ func Test_WithQueryOptimizerRules(t *testing.T) { defer c() col, err := db.CreateCollectionWithOptions(ctx, "test", nil, &arangodb.CreateCollectionOptions{ - EnforceReplicationFactor: newBool(false), + EnforceReplicationFactor: utils.NewT(false), }) require.NoError(t, err) diff --git a/v2/tests/database_collection_perf_test.go b/v2/tests/database_collection_perf_test.go index d6a5ac5d..548fdd4a 100644 --- a/v2/tests/database_collection_perf_test.go +++ b/v2/tests/database_collection_perf_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2020-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ import ( "fmt" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -42,7 +44,7 @@ func insertDocuments(t testing.TB, col arangodb.Collection, documents, batch int if len(b) == batch { insertBatch(t, context.Background(), col, &arangodb.CollectionDocumentCreateOptions{ - WithWaitForSync: newBool(true), + WithWaitForSync: utils.NewT(true), }, b) b = b[:0] } diff --git a/v2/tests/database_view-arangosearch-simple_test.go b/v2/tests/database_view-arangosearch-simple_test.go index 42e3a44c..11698206 100644 --- a/v2/tests/database_view-arangosearch-simple_test.go +++ b/v2/tests/database_view-arangosearch-simple_test.go @@ -23,6 +23,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -36,8 +38,8 @@ func Test_ArangoSearchSimple(t *testing.T) { viewName := GenerateUUID("test-view") opts := &arangodb.ArangoSearchViewProperties{ - CleanupIntervalStep: newInt64(1), - CommitInterval: newInt64(500), + CleanupIntervalStep: utils.NewInt64(1), + CommitInterval: utils.NewInt64(500), } view, err := db.CreateArangoSearchView(ctx, viewName, opts) @@ -52,7 +54,7 @@ func Test_ArangoSearchSimple(t *testing.T) { t.Run("Update properties of the view", func(t *testing.T) { opt := arangodb.ArangoSearchViewProperties{ - CommitInterval: newInt64(200), + CommitInterval: utils.NewInt64(200), } err = view.UpdateProperties(ctx, opt) require.NoError(t, err) @@ -67,7 +69,7 @@ func Test_ArangoSearchSimple(t *testing.T) { t.Run("Replace properties of the view", func(t *testing.T) { opt := arangodb.ArangoSearchViewProperties{ - CommitInterval: newInt64(300), + CommitInterval: utils.NewInt64(300), } err = view.SetProperties(ctx, opt) require.NoError(t, err) diff --git a/v2/tests/database_view-arangosearch_test.go b/v2/tests/database_view-arangosearch_test.go index 8f6e12dd..b019c12c 100644 --- a/v2/tests/database_view-arangosearch_test.go +++ b/v2/tests/database_view-arangosearch_test.go @@ -25,6 +25,8 @@ import ( "net/http" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -589,10 +591,10 @@ func Test_UseArangoSearchViewWithPipelineAnalyzer(t *testing.T) { { Type: arangodb.ArangoSearchAnalyzerTypeNGram, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Min: newT[int64](2), - Max: newT[int64](2), - PreserveOriginal: newBool(false), - StreamType: newT(arangodb.ArangoSearchNGramStreamUTF8), + Min: utils.NewT[int64](2), + Max: utils.NewT[int64](2), + PreserveOriginal: utils.NewT(false), + StreamType: utils.NewT(arangodb.ArangoSearchNGramStreamUTF8), }, }, { @@ -683,7 +685,7 @@ func Test_ArangoSearchViewProperties35(t *testing.T) { CommitInterval: &commitInterval, PrimarySort: []arangodb.ArangoSearchPrimarySortEntry{{ Field: sortField, - Ascending: newBool(false), + Ascending: utils.NewT(false), }}, StoredValues: []arangodb.StoredValue{{ Fields: storedValuesFields, @@ -826,8 +828,8 @@ func Test_ArangoSearchViewProperties353(t *testing.T) { }, }, }, - IncludeAllFields: newBool(true), - InBackground: newBool(false), + IncludeAllFields: utils.NewT(true), + InBackground: utils.NewT(false), }, }, } @@ -866,12 +868,12 @@ func Test_ArangoSearchViewLinkAndStoredValueCache(t *testing.T) { StoredValues: []arangodb.StoredValue{ { Fields: []string{"f1", "f2"}, - Cache: newBool(true), + Cache: utils.NewT(true), }, }, Links: arangodb.ArangoSearchLinks{ linkedColName: arangodb.ArangoSearchElementProperties{ - Cache: newBool(false), + Cache: utils.NewT(false), }, }, } @@ -881,13 +883,13 @@ func Test_ArangoSearchViewLinkAndStoredValueCache(t *testing.T) { p, err := v.Properties(ctx) require.NoError(t, err) require.Len(t, p.StoredValues, 1) - require.Equal(t, newBool(true), p.StoredValues[0].Cache) + require.Equal(t, utils.NewT(true), p.StoredValues[0].Cache) linkedColumnProps := p.Links[linkedColName] require.NotNil(t, linkedColumnProps) require.Nil(t, linkedColumnProps.Cache) // update props: set to cached - p.Links[linkedColName] = arangodb.ArangoSearchElementProperties{Cache: newBool(true)} + p.Links[linkedColName] = arangodb.ArangoSearchElementProperties{Cache: utils.NewT(true)} err = v.SetProperties(ctx, p) require.NoError(t, err) @@ -896,7 +898,7 @@ func Test_ArangoSearchViewLinkAndStoredValueCache(t *testing.T) { require.NoError(t, err) linkedColumnProps = p.Links[linkedColName] require.NotNil(t, linkedColumnProps) - require.Equal(t, newBool(true), linkedColumnProps.Cache) + require.Equal(t, utils.NewT(true), linkedColumnProps.Cache) }) }) }) @@ -917,7 +919,7 @@ func Test_ArangoSearchViewInMemoryCache(t *testing.T) { name := "test_create_asview" opts := &arangodb.ArangoSearchViewProperties{ - PrimarySortCache: newBool(true), + PrimarySortCache: utils.NewT(true), } v, err := db.CreateArangoSearchView(ctx, name, opts) require.NoError(t, err) @@ -927,7 +929,7 @@ func Test_ArangoSearchViewInMemoryCache(t *testing.T) { // bug in arangod: the primarySortCache field is not returned in response. Fixed only in 3.9.6+: t.Run("must-be-returned-in-response", func(t *testing.T) { skipBelowVersion(client, ctx, "3.9.6", t) - require.Equal(t, newBool(true), p.PrimarySortCache) + require.Equal(t, utils.NewT(true), p.PrimarySortCache) }) }) @@ -938,14 +940,14 @@ func Test_ArangoSearchViewInMemoryCache(t *testing.T) { name := "test_view_" opts := &arangodb.ArangoSearchViewProperties{ - PrimaryKeyCache: newBool(true), + PrimaryKeyCache: utils.NewT(true), } v, err := db.CreateArangoSearchView(ctx, name, opts) require.NoError(t, err) p, err := v.Properties(ctx) require.NoError(t, err) - require.Equal(t, newBool(true), p.PrimaryKeyCache) + require.Equal(t, utils.NewT(true), p.PrimaryKeyCache) }) }) }) diff --git a/v2/tests/graph_edge_definitions_edges_test.go b/v2/tests/graph_edge_definitions_edges_test.go index ac132b71..96d22ede 100644 --- a/v2/tests/graph_edge_definitions_edges_test.go +++ b/v2/tests/graph_edge_definitions_edges_test.go @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -56,7 +58,7 @@ func Test_EdgeSimple(t *testing.T) { t.Run("Create Edge", func(t *testing.T) { opts := arangodb.CreateEdgeOptions{ - WaitForSync: newBool(true), + WaitForSync: utils.NewT(true), } createEdgeResp, err := edgeDefResp.Edge.CreateEdge(ctx, doc, &opts) require.NoError(t, err) @@ -83,7 +85,7 @@ func Test_EdgeSimple(t *testing.T) { t.Run("Update Edge", func(t *testing.T) { opts := arangodb.EdgeUpdateOptions{ - WaitForSync: newBool(true), + WaitForSync: utils.NewT(true), } updateEdgeResp, err := edgeDefResp.Edge.UpdateEdge(ctx, docKey, map[string]int{"distance": 10}, &opts) require.NoError(t, err) @@ -103,7 +105,7 @@ func Test_EdgeSimple(t *testing.T) { t.Run("Replace Edge", func(t *testing.T) { opts := arangodb.EdgeReplaceOptions{ - WaitForSync: newBool(true), + WaitForSync: utils.NewT(true), } docReplace := RouteEdge{ @@ -167,7 +169,7 @@ func Test_EdgeExtended(t *testing.T) { t.Run("Create Edge", func(t *testing.T) { var newObject RouteEdge opts := arangodb.CreateEdgeOptions{ - WaitForSync: newBool(true), + WaitForSync: utils.NewT(true), NewObject: &newObject, } @@ -201,7 +203,7 @@ func Test_EdgeExtended(t *testing.T) { t.Run("Update Edge", func(t *testing.T) { var oldObject RouteEdge opts := arangodb.EdgeUpdateOptions{ - WaitForSync: newBool(true), + WaitForSync: utils.NewT(true), OldObject: &oldObject, } updateEdgeResp, err := edgeDefResp.Edge.UpdateEdge(ctx, docKey, map[string]int{"distance": 10}, &opts) @@ -228,7 +230,7 @@ func Test_EdgeExtended(t *testing.T) { opts := arangodb.EdgeReplaceOptions{ OldObject: &oldObject, NewObject: &newObject, - WaitForSync: newBool(true), + WaitForSync: utils.NewT(true), } docReplace := RouteEdge{ diff --git a/v2/tests/graph_edge_definitions_test.go b/v2/tests/graph_edge_definitions_test.go index 4616373e..6e64d1f4 100644 --- a/v2/tests/graph_edge_definitions_test.go +++ b/v2/tests/graph_edge_definitions_test.go @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -127,7 +129,7 @@ func TestGraphEdgeDefinitionsRemovalCollections(t *testing.T) { edgeDef := gDef.EdgeDefinitions[0] opts := arangodb.DeleteEdgeDefinitionOptions{ - DropCollection: newBool(true), + DropCollection: utils.NewT(true), } delResp, err := graph.DeleteEdgeDefinition(ctx, edgeDef.Collection, &opts) require.NoError(t, err) diff --git a/v2/tests/graph_helper_test.go b/v2/tests/graph_helper_test.go index 8506ddda..ecfdd8ae 100644 --- a/v2/tests/graph_helper_test.go +++ b/v2/tests/graph_helper_test.go @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -32,7 +34,7 @@ import ( func sampleSmartGraph() *arangodb.GraphDefinition { return &arangodb.GraphDefinition{ - NumberOfShards: newInt(3), + NumberOfShards: utils.NewT(3), SmartGraphAttribute: "key", IsSmart: true, } diff --git a/v2/tests/graph_test.go b/v2/tests/graph_test.go index 9d8172df..6dfd0cc9 100644 --- a/v2/tests/graph_test.go +++ b/v2/tests/graph_test.go @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -36,7 +38,7 @@ func Test_GraphSimple(t *testing.T) { WithDatabase(t, client, nil, func(db arangodb.Database) { gDef := sampleGraphWithEdges(db) gDef.ReplicationFactor = 2 - gDef.WriteConcern = newInt(2) + gDef.WriteConcern = utils.NewT(2) WithGraph(t, db, gDef, nil, func(graph arangodb.Graph) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { exist, err := db.GraphExists(ctx, graph.Name()) @@ -100,7 +102,7 @@ func Test_GraphCreation(t *testing.T) { gDef.ReplicationFactor = arangodb.SatelliteGraph gDef.IsSmart = false gDef.SmartGraphAttribute = "" - gDef.NumberOfShards = newInt(1) + gDef.NumberOfShards = utils.NewT(1) g, err := db.CreateGraph(ctx, db.Name()+"_sat", gDef, nil) require.NoError(t, err) @@ -145,7 +147,7 @@ func Test_GraphCreation(t *testing.T) { From: []string{colNonSat}, }, }, - NumberOfShards: newInt(2), + NumberOfShards: utils.NewT(2), SmartGraphAttribute: "test", IsSmart: true, ReplicationFactor: 2, diff --git a/v2/tests/graph_vertex_collections_test.go b/v2/tests/graph_vertex_collections_test.go index 2ed0ec6f..171ee8a7 100644 --- a/v2/tests/graph_vertex_collections_test.go +++ b/v2/tests/graph_vertex_collections_test.go @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -112,7 +114,7 @@ func TestCreateSatelliteVertexCollection(t *testing.T) { t.Run("Deleting Vertex should remove the collection when requested", func(t *testing.T) { opts := arangodb.DeleteVertexCollectionOptions{ - DropCollection: newBool(true), + DropCollection: utils.NewT(true), } delResp, err := graph.DeleteVertexCollection(ctx, colName, &opts) require.NoError(t, err) diff --git a/v2/tests/graph_vertex_collections_vertices_test.go b/v2/tests/graph_vertex_collections_vertices_test.go index 8b96b0e5..333d29d3 100644 --- a/v2/tests/graph_vertex_collections_vertices_test.go +++ b/v2/tests/graph_vertex_collections_vertices_test.go @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -236,7 +238,7 @@ func Test_VerticesUpdate(t *testing.T) { john := Developer{ Name: "John", - IsAdmin: newBool(true), + IsAdmin: utils.NewT(true), } johnResp, err := colVertex.CreateVertex(ctx, john, nil) @@ -249,7 +251,7 @@ func Test_VerticesUpdate(t *testing.T) { opts := arangodb.VertexUpdateOptions{ NewObject: &johnUpdated, - KeepNull: newBool(true), + KeepNull: utils.NewT(true), } response, err := colVertex.UpdateVertex(ctx, johnResp.Key, johnUpdated, &opts) @@ -272,7 +274,7 @@ func Test_VerticesUpdate(t *testing.T) { opts := arangodb.VertexUpdateOptions{ NewObject: &johnUpdated, - KeepNull: newBool(false), + KeepNull: utils.NewT(false), } response, err := colVertex.UpdateVertex(ctx, johnResp.Key, johnUpdated, &opts) diff --git a/v2/tests/helper_test.go b/v2/tests/helper_test.go index 92be074b..c5392bbd 100644 --- a/v2/tests/helper_test.go +++ b/v2/tests/helper_test.go @@ -27,6 +27,8 @@ import ( "testing" "time" + "github.com/arangodb/go-driver/v2/utils" + "github.com/google/uuid" "github.com/stretchr/testify/require" @@ -164,22 +166,6 @@ func getBool(b *bool, d bool) bool { return *b } -func newBool(b bool) *bool { - return newT(b) -} - -func newT[T any](val T) *T { - return &val -} - func newVersion(val string) *arangodb.Version { - return newT(arangodb.Version(val)) -} - -func newInt(i int) *int { - return &i -} - -func newInt64(i int64) *int64 { - return &i + return utils.NewT(arangodb.Version(val)) } diff --git a/v2/tests/users_permissions_test.go b/v2/tests/users_permissions_test.go index 518ea6a0..4adfc69d 100644 --- a/v2/tests/users_permissions_test.go +++ b/v2/tests/users_permissions_test.go @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -116,6 +118,6 @@ func Test_UserPermission(t *testing.T) { }) }) }, WrapOptions{ - Parallel: newBool(false), + Parallel: utils.NewT(false), }) } diff --git a/v2/tests/users_test.go b/v2/tests/users_test.go index 7328be32..a5e8bf7c 100644 --- a/v2/tests/users_test.go +++ b/v2/tests/users_test.go @@ -24,6 +24,8 @@ import ( "context" "testing" + "github.com/arangodb/go-driver/v2/utils" + "github.com/stretchr/testify/require" "github.com/arangodb/go-driver/v2/arangodb" @@ -96,7 +98,7 @@ func Test_Users(t *testing.T) { t.Run("Test update user", func(t *testing.T) { opts := &arangodb.UserOptions{ - Active: newBool(false), + Active: utils.NewT(false), } u, err := client.UpdateUser(ctx, user1Name, opts) @@ -132,7 +134,7 @@ func Test_Users(t *testing.T) { }) }) }, WrapOptions{ - Parallel: newBool(false), + Parallel: utils.NewT(false), }) } @@ -141,8 +143,8 @@ func Test_UserCreation(t *testing.T) { testCases := map[string]*arangodb.UserOptions{ "jan1": nil, - "george": {Password: "foo", Active: newBool(false)}, - "candy": {Password: "ARANGODB_DEFAULT_ROOT_PASSWORD", Active: newBool(true)}, + "george": {Password: "foo", Active: utils.NewT(false)}, + "candy": {Password: "ARANGODB_DEFAULT_ROOT_PASSWORD", Active: utils.NewT(true)}, "joe": {Extra: map[string]interface{}{"key": "value", "x": 5}}, "admin@api": nil, "測試用例": nil, @@ -179,6 +181,6 @@ func Test_UserCreation(t *testing.T) { }) } }, WrapOptions{ - Parallel: newBool(false), + Parallel: utils.NewT(false), }) } diff --git a/v2/utils/type.go b/v2/utils/type.go index 30ab0bb1..aa0fc5c8 100644 --- a/v2/utils/type.go +++ b/v2/utils/type.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2020 ArangoDB GmbH, Cologne, Germany +// Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,8 +17,6 @@ // // Copyright holder is ArangoDB GmbH, Cologne, Germany // -// Author Adam Janikowski -// package utils @@ -44,3 +42,11 @@ func IsList(i interface{}) bool { return false } } + +func NewT[T any](val T) *T { + return &val +} + +func NewInt64(i int64) *int64 { + return &i +} From 49c887ba20b9c7ff86678abf2a7d0fe73fea89a7 Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Thu, 3 Oct 2024 14:29:08 +0200 Subject: [PATCH 2/5] Fix linter --- test/arangosearch_analyzers_test.go | 3 +-- test/collection_test.go | 3 +-- test/index_ensure_test.go | 3 +-- test/view_alias_test.go | 3 +-- test/view_test.go | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/test/arangosearch_analyzers_test.go b/test/arangosearch_analyzers_test.go index 0eb1e4e2..740fb52e 100644 --- a/test/arangosearch_analyzers_test.go +++ b/test/arangosearch_analyzers_test.go @@ -25,11 +25,10 @@ import ( "encoding/json" "testing" - "github.com/arangodb/go-driver/util" - "github.com/stretchr/testify/require" "github.com/arangodb/go-driver" + "github.com/arangodb/go-driver/util" ) func newInt(v int) *int { diff --git a/test/collection_test.go b/test/collection_test.go index d84d8d93..f724d582 100644 --- a/test/collection_test.go +++ b/test/collection_test.go @@ -27,12 +27,11 @@ import ( "testing" "time" - "github.com/arangodb/go-driver/util" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" driver "github.com/arangodb/go-driver" + "github.com/arangodb/go-driver/util" ) // ensureCollection is a helper to check if a collection exists and create if if needed. diff --git a/test/index_ensure_test.go b/test/index_ensure_test.go index 19f1ec18..9e3f34b4 100644 --- a/test/index_ensure_test.go +++ b/test/index_ensure_test.go @@ -25,12 +25,11 @@ import ( "fmt" "testing" - "github.com/arangodb/go-driver/util" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" driver "github.com/arangodb/go-driver" + "github.com/arangodb/go-driver/util" ) // TestEnsureFullTextIndex creates a collection with a full text index. diff --git a/test/view_alias_test.go b/test/view_alias_test.go index 6a172186..964643bb 100644 --- a/test/view_alias_test.go +++ b/test/view_alias_test.go @@ -24,11 +24,10 @@ import ( "context" "testing" - "github.com/arangodb/go-driver/util" - "github.com/stretchr/testify/require" "github.com/arangodb/go-driver" + "github.com/arangodb/go-driver/util" ) // ensureArangoSearchView is a helper to check if an arangosearch view exists and create it if needed. diff --git a/test/view_test.go b/test/view_test.go index d668cba1..6d067321 100644 --- a/test/view_test.go +++ b/test/view_test.go @@ -26,12 +26,11 @@ import ( "net/http" "testing" - "github.com/arangodb/go-driver/util" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/arangodb/go-driver" + "github.com/arangodb/go-driver/util" ) // ensureArangoSearchView is a helper to check if an arangosearch view exists and create it if needed. From 4b279792e9a8da7dec1e673ec1e4a75508fd50fa Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Fri, 4 Oct 2024 09:29:52 +0200 Subject: [PATCH 3/5] Update --- v2/tests/database_view-arangosearch-simple_test.go | 8 ++++---- v2/utils/type.go | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/v2/tests/database_view-arangosearch-simple_test.go b/v2/tests/database_view-arangosearch-simple_test.go index 11698206..ce98c318 100644 --- a/v2/tests/database_view-arangosearch-simple_test.go +++ b/v2/tests/database_view-arangosearch-simple_test.go @@ -38,8 +38,8 @@ func Test_ArangoSearchSimple(t *testing.T) { viewName := GenerateUUID("test-view") opts := &arangodb.ArangoSearchViewProperties{ - CleanupIntervalStep: utils.NewInt64(1), - CommitInterval: utils.NewInt64(500), + CleanupIntervalStep: utils.NewT[int64](1), + CommitInterval: utils.NewT[int64](500), } view, err := db.CreateArangoSearchView(ctx, viewName, opts) @@ -54,7 +54,7 @@ func Test_ArangoSearchSimple(t *testing.T) { t.Run("Update properties of the view", func(t *testing.T) { opt := arangodb.ArangoSearchViewProperties{ - CommitInterval: utils.NewInt64(200), + CommitInterval: utils.NewT[int64](200), } err = view.UpdateProperties(ctx, opt) require.NoError(t, err) @@ -69,7 +69,7 @@ func Test_ArangoSearchSimple(t *testing.T) { t.Run("Replace properties of the view", func(t *testing.T) { opt := arangodb.ArangoSearchViewProperties{ - CommitInterval: utils.NewInt64(300), + CommitInterval: utils.NewT[int64](300), } err = view.SetProperties(ctx, opt) require.NoError(t, err) diff --git a/v2/utils/type.go b/v2/utils/type.go index aa0fc5c8..17de728c 100644 --- a/v2/utils/type.go +++ b/v2/utils/type.go @@ -46,7 +46,3 @@ func IsList(i interface{}) bool { func NewT[T any](val T) *T { return &val } - -func NewInt64(i int64) *int64 { - return &i -} From 636b4425f1bf927fcf8cf3011fb085b284a4dfa0 Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Fri, 4 Oct 2024 09:31:27 +0200 Subject: [PATCH 4/5] Update --- test/arangosearch_analyzers_test.go | 56 ++++++------ test/collection_test.go | 8 +- test/index_ensure_test.go | 10 +-- test/view_alias_test.go | 4 +- test/view_test.go | 26 +++--- util/type.go | 2 +- v2/tests/admin_log_test.go | 4 +- v2/tests/admin_test.go | 4 +- v2/tests/asyncjob_test.go | 4 +- v2/tests/backup_test.go | 8 +- v2/tests/database_analyzer_test.go | 90 +++++++++---------- .../database_collection_doc_create_test.go | 32 +++---- .../database_collection_doc_delete_test.go | 18 ++-- v2/tests/database_collection_doc_read_test.go | 8 +- .../database_collection_doc_replace_test.go | 26 +++--- .../database_collection_doc_update_test.go | 36 ++++---- v2/tests/database_collection_indexes_test.go | 40 ++++----- .../database_collection_operations_test.go | 8 +- v2/tests/database_collection_perf_test.go | 2 +- .../database_view-arangosearch-simple_test.go | 8 +- v2/tests/database_view-arangosearch_test.go | 32 +++---- v2/tests/graph_edge_definitions_edges_test.go | 12 +-- v2/tests/graph_edge_definitions_test.go | 2 +- v2/tests/graph_helper_test.go | 2 +- v2/tests/graph_test.go | 6 +- v2/tests/graph_vertex_collections_test.go | 2 +- .../graph_vertex_collections_vertices_test.go | 6 +- v2/tests/helper_test.go | 2 +- v2/tests/users_permissions_test.go | 2 +- v2/tests/users_test.go | 10 +-- v2/utils/type.go | 2 +- 31 files changed, 236 insertions(+), 236 deletions(-) diff --git a/test/arangosearch_analyzers_test.go b/test/arangosearch_analyzers_test.go index 740fb52e..26456bb6 100644 --- a/test/arangosearch_analyzers_test.go +++ b/test/arangosearch_analyzers_test.go @@ -140,7 +140,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: util.NewT(false), + PreserveOriginal: util.NewType(false), }, }, }, @@ -153,7 +153,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: util.NewT(false), + PreserveOriginal: util.NewType(false), }, }, ExpectedDefinition: &driver.ArangoSearchAnalyzerDefinition{ @@ -162,7 +162,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: util.NewT(false), + PreserveOriginal: util.NewType(false), // Check defaults for 3.6 StartMarker: newString(""), @@ -180,7 +180,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: util.NewT(false), + PreserveOriginal: util.NewType(false), StartMarker: newString("^"), EndMarker: newString("^"), StreamType: newArangoSearchNGramStreamType(driver.ArangoSearchNGramStreamUTF8), @@ -200,7 +200,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: util.NewT(false), + PreserveOriginal: util.NewType(false), StartMarker: newString("^"), EndMarker: newString("^"), StreamType: newArangoSearchNGramStreamType(driver.ArangoSearchNGramStreamUTF8), @@ -218,11 +218,11 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Type: driver.ArangoSearchAnalyzerTypeAQL, Properties: driver.ArangoSearchAnalyzerProperties{ QueryString: `FOR year IN [ 2011, 2012, 2013 ] FOR quarter IN [ 1, 2, 3, 4 ] RETURN { year, quarter, formatted: CONCAT(quarter, " / ", year)}`, - CollapsePositions: util.NewT(true), - KeepNull: util.NewT(false), - BatchSize: util.NewT(10), + CollapsePositions: util.NewType(true), + KeepNull: util.NewType(false), + BatchSize: util.NewType(10), ReturnType: driver.ArangoSearchAnalyzerAQLReturnTypeString.New(), - MemoryLimit: util.NewT(1024 * 1024), + MemoryLimit: util.NewType(1024 * 1024), }, }, }, @@ -234,9 +234,9 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Type: driver.ArangoSearchAnalyzerTypeGeoPoint, Properties: driver.ArangoSearchAnalyzerProperties{ Options: &driver.ArangoSearchAnalyzerGeoOptions{ - MaxCells: util.NewT(20), - MinLevel: util.NewT(4), - MaxLevel: util.NewT(23), + MaxCells: util.NewType(20), + MinLevel: util.NewType(4), + MaxLevel: util.NewType(23), }, Latitude: []string{}, Longitude: []string{}, @@ -251,9 +251,9 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Type: driver.ArangoSearchAnalyzerTypeGeoJSON, Properties: driver.ArangoSearchAnalyzerProperties{ Options: &driver.ArangoSearchAnalyzerGeoOptions{ - MaxCells: util.NewT(20), - MinLevel: util.NewT(4), - MaxLevel: util.NewT(23), + MaxCells: util.NewType(20), + MinLevel: util.NewType(4), + MaxLevel: util.NewType(23), }, Type: driver.ArangoSearchAnalyzerGeoJSONTypeShape.New(), }, @@ -268,9 +268,9 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Format: driver.FormatLatLngInt.New(), Options: &driver.ArangoSearchAnalyzerGeoOptions{ - MaxCells: util.NewT(20), - MinLevel: util.NewT(4), - MaxLevel: util.NewT(23), + MaxCells: util.NewType(20), + MinLevel: util.NewType(4), + MaxLevel: util.NewType(23), }, Type: driver.ArangoSearchAnalyzerGeoJSONTypeShape.New(), }, @@ -281,9 +281,9 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Format: driver.FormatLatLngInt.New(), Options: &driver.ArangoSearchAnalyzerGeoOptions{ - MaxCells: util.NewT(20), - MinLevel: util.NewT(4), - MaxLevel: util.NewT(23), + MaxCells: util.NewType(20), + MinLevel: util.NewType(4), + MaxLevel: util.NewType(23), }, Type: driver.ArangoSearchAnalyzerGeoJSONTypeShape.New(), }, @@ -327,7 +327,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Name: "my-stopWords", Type: driver.ArangoSearchAnalyzerTypeStopwords, Properties: driver.ArangoSearchAnalyzerProperties{ - Hex: util.NewT(true), + Hex: util.NewType(true), Stopwords: []string{ "616e64", "746865", @@ -338,7 +338,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Name: "my-stopWords", Type: driver.ArangoSearchAnalyzerTypeStopwords, Properties: driver.ArangoSearchAnalyzerProperties{ - Hex: util.NewT(true), + Hex: util.NewType(true), Stopwords: []string{ "616e64", "746865", @@ -357,7 +357,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Analyzer: &driver.ArangoSearchAnalyzerDefinition{ Type: driver.ArangoSearchAnalyzerTypeStopwords, Properties: driver.ArangoSearchAnalyzerProperties{ - Hex: util.NewT(true), + Hex: util.NewType(true), Stopwords: []string{ "616e64", "746865", @@ -374,7 +374,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) { Analyzer: &driver.ArangoSearchAnalyzerDefinition{ Type: driver.ArangoSearchAnalyzerTypeStopwords, Properties: driver.ArangoSearchAnalyzerProperties{ - Hex: util.NewT(true), + Hex: util.NewType(true), Stopwords: []string{ "616e64", "746865", @@ -451,7 +451,7 @@ func TestArangoSearchAnalyzerGet(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: util.NewT(false), + PreserveOriginal: util.NewType(false), }, } ensureAnalyzer(ctx, db, def, t) @@ -485,7 +485,7 @@ func TestArangoSearchAnalyzerGetAll(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: util.NewT(false), + PreserveOriginal: util.NewType(false), }, } ensureAnalyzer(ctx, db, def, t) @@ -525,7 +525,7 @@ func TestArangoSearchAnalyzerRemove(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(1), Max: newInt64(14), - PreserveOriginal: util.NewT(false), + PreserveOriginal: util.NewType(false), }, } a := ensureAnalyzer(ctx, db, def, t) diff --git a/test/collection_test.go b/test/collection_test.go index f724d582..1420dd59 100644 --- a/test/collection_test.go +++ b/test/collection_test.go @@ -115,7 +115,7 @@ func TestCollection_CacheEnabled(t *testing.T) { t.Run("False", func(t *testing.T) { name := "test_create_collection_cache_false" _, err := db.CreateCollection(nil, name, &driver.CreateCollectionOptions{ - CacheEnabled: util.NewT(false), + CacheEnabled: util.NewType(false), }) require.NoError(t, err) @@ -132,7 +132,7 @@ func TestCollection_CacheEnabled(t *testing.T) { t.Run("True", func(t *testing.T) { name := "test_create_collection_cache_true" _, err := db.CreateCollection(nil, name, &driver.CreateCollectionOptions{ - CacheEnabled: util.NewT(true), + CacheEnabled: util.NewType(true), }) require.NoError(t, err) @@ -149,7 +149,7 @@ func TestCollection_CacheEnabled(t *testing.T) { t.Run("With update", func(t *testing.T) { name := "test_create_collection_cache_update" _, err := db.CreateCollection(nil, name, &driver.CreateCollectionOptions{ - CacheEnabled: util.NewT(false), + CacheEnabled: util.NewType(false), }) require.NoError(t, err) @@ -163,7 +163,7 @@ func TestCollection_CacheEnabled(t *testing.T) { require.False(t, prop.CacheEnabled) err = col.SetProperties(nil, driver.SetCollectionPropertiesOptions{ - CacheEnabled: util.NewT(true), + CacheEnabled: util.NewType(true), }) require.NoError(t, err) diff --git a/test/index_ensure_test.go b/test/index_ensure_test.go index 9e3f34b4..75fefa9e 100644 --- a/test/index_ensure_test.go +++ b/test/index_ensure_test.go @@ -538,8 +538,8 @@ func TestEnsureInvertedIndex(t *testing.T) { Name: "inverted-opt", PrimarySort: driver.InvertedIndexPrimarySort{ Fields: []driver.ArangoSearchPrimarySortEntry{ - {Field: "test1", Ascending: util.NewT(true)}, - {Field: "test2", Ascending: util.NewT(false)}, + {Field: "test1", Ascending: util.NewType(true)}, + {Field: "test2", Ascending: util.NewType(false)}, }, Compression: driver.PrimarySortCompressionLz4, }, @@ -555,8 +555,8 @@ func TestEnsureInvertedIndex(t *testing.T) { Name: "inverted-opt-nested", PrimarySort: driver.InvertedIndexPrimarySort{ Fields: []driver.ArangoSearchPrimarySortEntry{ - {Field: "test1", Ascending: util.NewT(true)}, - {Field: "test2", Ascending: util.NewT(false)}, + {Field: "test1", Ascending: util.NewType(true)}, + {Field: "test2", Ascending: util.NewType(false)}, }, Compression: driver.PrimarySortCompressionLz4, }, @@ -589,7 +589,7 @@ func TestEnsureInvertedIndex(t *testing.T) { Name: "inverted-opt-optimize-top-k", PrimarySort: driver.InvertedIndexPrimarySort{ Fields: []driver.ArangoSearchPrimarySortEntry{ - {Field: "field1", Ascending: util.NewT(true)}, + {Field: "field1", Ascending: util.NewType(true)}, }, Compression: driver.PrimarySortCompressionLz4, }, diff --git a/test/view_alias_test.go b/test/view_alias_test.go index 964643bb..15a9990f 100644 --- a/test/view_alias_test.go +++ b/test/view_alias_test.go @@ -77,8 +77,8 @@ func TestSearchViewsAlias(t *testing.T) { Name: nameInvInd, PrimarySort: driver.InvertedIndexPrimarySort{ Fields: []driver.ArangoSearchPrimarySortEntry{ - {Field: "test1", Ascending: util.NewT(true)}, - {Field: "test2", Ascending: util.NewT(false)}, + {Field: "test1", Ascending: util.NewType(true)}, + {Field: "test2", Ascending: util.NewType(false)}, }, Compression: driver.PrimarySortCompressionLz4, }, diff --git a/test/view_test.go b/test/view_test.go index 6d067321..4cafe330 100644 --- a/test/view_test.go +++ b/test/view_test.go @@ -634,7 +634,7 @@ func TestUseArangoSearchViewWithPipelineAnalyzer(t *testing.T) { Properties: driver.ArangoSearchAnalyzerProperties{ Min: newInt64(2), Max: newInt64(2), - PreserveOriginal: util.NewT(false), + PreserveOriginal: util.NewType(false), StreamType: newArangoSearchNGramStreamType(driver.ArangoSearchNGramStreamUTF8), }, }, @@ -952,8 +952,8 @@ func TestArangoSearchViewProperties353(t *testing.T) { }, }, }, - IncludeAllFields: util.NewT(true), - InBackground: util.NewT(false), + IncludeAllFields: util.NewType(true), + InBackground: util.NewType(false), }, }, } @@ -988,7 +988,7 @@ func TestArangoSearchViewProperties353(t *testing.T) { require.Contains(t, analyzer.Features, driver.ArangoSearchAnalyzerFeaturePosition) require.EqualValues(t, analyzer.Properties.Locale, "en_US") require.EqualValues(t, analyzer.Properties.Case, driver.ArangoSearchCaseLower) - require.Equal(t, util.NewT(true), link.IncludeAllFields) + require.Equal(t, util.NewType(true), link.IncludeAllFields) } func TestArangoSearchViewLinkAndStoredValueCache(t *testing.T) { @@ -1006,12 +1006,12 @@ func TestArangoSearchViewLinkAndStoredValueCache(t *testing.T) { StoredValues: []driver.StoredValue{ { Fields: []string{"f1", "f2"}, - Cache: util.NewT(true), + Cache: util.NewType(true), }, }, Links: driver.ArangoSearchLinks{ linkedColName: driver.ArangoSearchElementProperties{ - Cache: util.NewT(false), + Cache: util.NewType(false), }, }, } @@ -1022,12 +1022,12 @@ func TestArangoSearchViewLinkAndStoredValueCache(t *testing.T) { p, err := v.Properties(ctx) require.NoError(t, err) require.Len(t, p.StoredValues, 1) - require.Equal(t, util.NewT(true), p.StoredValues[0].Cache) + require.Equal(t, util.NewType(true), p.StoredValues[0].Cache) linkedColumnProps := p.Links[linkedColName] require.NotNil(t, linkedColumnProps) require.Nil(t, linkedColumnProps.Cache) // update props: set to cached - p.Links[linkedColName] = driver.ArangoSearchElementProperties{Cache: util.NewT(true)} + p.Links[linkedColName] = driver.ArangoSearchElementProperties{Cache: util.NewType(true)} err = v.SetProperties(ctx, p) require.NoError(t, err) @@ -1036,7 +1036,7 @@ func TestArangoSearchViewLinkAndStoredValueCache(t *testing.T) { require.NoError(t, err) linkedColumnProps = p.Links[linkedColName] require.NotNil(t, linkedColumnProps) - require.Equal(t, util.NewT(true), linkedColumnProps.Cache) + require.Equal(t, util.NewType(true), linkedColumnProps.Cache) } func TestArangoSearchViewInMemoryCache(t *testing.T) { @@ -1053,7 +1053,7 @@ func TestArangoSearchViewInMemoryCache(t *testing.T) { name := "test_create_asview" opts := &driver.ArangoSearchViewProperties{ - PrimarySortCache: util.NewT(true), + PrimarySortCache: util.NewType(true), } v, err := db.CreateArangoSearchView(ctx, name, opts) require.NoError(t, err) @@ -1063,7 +1063,7 @@ func TestArangoSearchViewInMemoryCache(t *testing.T) { // bug in arangod: the primarySortCache field is not returned in response. Fixed only in 3.9.6+: t.Run("must-be-returned-in-response", func(t *testing.T) { skipBelowVersion(c, "3.9.6", t) - require.Equal(t, util.NewT(true), p.PrimarySortCache) + require.Equal(t, util.NewType(true), p.PrimarySortCache) }) }) @@ -1074,13 +1074,13 @@ func TestArangoSearchViewInMemoryCache(t *testing.T) { name := "test_view_" opts := &driver.ArangoSearchViewProperties{ - PrimaryKeyCache: util.NewT(true), + PrimaryKeyCache: util.NewType(true), } v, err := db.CreateArangoSearchView(ctx, name, opts) require.NoError(t, err) p, err := v.Properties(ctx) require.NoError(t, err) - require.Equal(t, util.NewT(true), p.PrimaryKeyCache) + require.Equal(t, util.NewType(true), p.PrimaryKeyCache) }) } diff --git a/util/type.go b/util/type.go index bdc6a58b..202a7ca8 100644 --- a/util/type.go +++ b/util/type.go @@ -20,6 +20,6 @@ package util -func NewT[T any](val T) *T { +func NewType[T any](val T) *T { return &val } diff --git a/v2/tests/admin_log_test.go b/v2/tests/admin_log_test.go index 6b974102..10ff5015 100644 --- a/v2/tests/admin_log_test.go +++ b/v2/tests/admin_log_test.go @@ -36,7 +36,7 @@ import ( func Test_LogLevels(t *testing.T) { // This test cannot run subtests parallel, because it changes admin settings. wrapOpts := WrapOptions{ - Parallel: utils.NewT(false), + Parallel: utils.NewType(false), } Wrap(t, func(t *testing.T, client arangodb.Client) { @@ -72,7 +72,7 @@ func Test_LogLevelsForServers(t *testing.T) { // This test cannot run subtests parallel, because it changes admin settings. wrapOpts := WrapOptions{ - Parallel: utils.NewT(false), + Parallel: utils.NewType(false), } Wrap(t, func(t *testing.T, client arangodb.Client) { diff --git a/v2/tests/admin_test.go b/v2/tests/admin_test.go index cc9ca3e3..0713a578 100644 --- a/v2/tests/admin_test.go +++ b/v2/tests/admin_test.go @@ -34,7 +34,7 @@ import ( func Test_ServerMode(t *testing.T) { // This test can not run sub-tests parallelly, because it changes admin settings. wrapOpts := WrapOptions{ - Parallel: utils.NewT(false), + Parallel: utils.NewType(false), } Wrap(t, func(t *testing.T, client arangodb.Client) { @@ -79,7 +79,7 @@ func Test_Version(t *testing.T) { Wrap(t, func(t *testing.T, client arangodb.Client) { withContextT(t, time.Minute, func(ctx context.Context, t testing.TB) { v, err := client.VersionWithOptions(context.Background(), &arangodb.GetVersionOptions{ - Details: utils.NewT(true), + Details: utils.NewType(true), }) require.NoError(t, err) require.NotEmpty(t, v.Version) diff --git a/v2/tests/asyncjob_test.go b/v2/tests/asyncjob_test.go index 60e27046..75baa55d 100644 --- a/v2/tests/asyncjob_test.go +++ b/v2/tests/asyncjob_test.go @@ -35,8 +35,8 @@ import ( ) var asyncTestOpt = WrapOptions{ - Async: utils.NewT(true), - Parallel: utils.NewT(false), + Async: utils.NewType(true), + Parallel: utils.NewType(false), } func TestAsyncJobListDone(t *testing.T) { diff --git a/v2/tests/backup_test.go b/v2/tests/backup_test.go index 4a4b27cb..5755788b 100644 --- a/v2/tests/backup_test.go +++ b/v2/tests/backup_test.go @@ -88,7 +88,7 @@ func Test_CreateBackupSimple(t *testing.T) { require.NoError(t, err, "DeleteBackup failed") }) }, WrapOptions{ - Parallel: utils.NewT(false), + Parallel: utils.NewType(false), }) } @@ -142,7 +142,7 @@ func Test_RestoreBackupSimple(t *testing.T) { }) }) }, WrapOptions{ - Parallel: utils.NewT(false), + Parallel: utils.NewType(false), }) } @@ -227,7 +227,7 @@ func Test_BackupFullFlow(t *testing.T) { waitForSync(t, ctx, client) }) }, WrapOptions{ - Parallel: utils.NewT(false), + Parallel: utils.NewType(false), }) } @@ -263,7 +263,7 @@ func Test_UploadBackupFailAndAbort(t *testing.T) { }) }) }, WrapOptions{ - Parallel: utils.NewT(false), + Parallel: utils.NewType(false), }) } diff --git a/v2/tests/database_analyzer_test.go b/v2/tests/database_analyzer_test.go index c62b4325..4c852d45 100644 --- a/v2/tests/database_analyzer_test.go +++ b/v2/tests/database_analyzer_test.go @@ -97,23 +97,23 @@ func Test_Analyzers(t *testing.T) { Name: "my-ngram", Type: arangodb.ArangoSearchAnalyzerTypeNGram, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Min: utils.NewT[int64](1), - Max: utils.NewT[int64](14), - PreserveOriginal: utils.NewT(false), + Min: utils.NewType[int64](1), + Max: utils.NewType[int64](14), + PreserveOriginal: utils.NewType(false), }, }, ExpectedDefinition: &arangodb.AnalyzerDefinition{ Name: "my-ngram", Type: arangodb.ArangoSearchAnalyzerTypeNGram, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Min: utils.NewT[int64](1), - Max: utils.NewT[int64](14), - PreserveOriginal: utils.NewT(false), + Min: utils.NewType[int64](1), + Max: utils.NewType[int64](14), + PreserveOriginal: utils.NewType(false), // Check defaults for 3.6 - StartMarker: utils.NewT(""), - EndMarker: utils.NewT(""), - StreamType: utils.NewT(arangodb.ArangoSearchNGramStreamBinary), + StartMarker: utils.NewType(""), + EndMarker: utils.NewType(""), + StreamType: utils.NewType(arangodb.ArangoSearchNGramStreamBinary), }, }, }, @@ -124,12 +124,12 @@ func Test_Analyzers(t *testing.T) { Name: "my-ngram-custom", Type: arangodb.ArangoSearchAnalyzerTypeNGram, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Min: utils.NewT[int64](1), - Max: utils.NewT[int64](14), - PreserveOriginal: utils.NewT(false), - StartMarker: utils.NewT("^"), - EndMarker: utils.NewT("^"), - StreamType: utils.NewT(arangodb.ArangoSearchNGramStreamUTF8), + Min: utils.NewType[int64](1), + Max: utils.NewType[int64](14), + PreserveOriginal: utils.NewType(false), + StartMarker: utils.NewType("^"), + EndMarker: utils.NewType("^"), + StreamType: utils.NewType(arangodb.ArangoSearchNGramStreamUTF8), }, }, }, @@ -144,12 +144,12 @@ func Test_Analyzers(t *testing.T) { { Type: arangodb.ArangoSearchAnalyzerTypeNGram, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Min: utils.NewT[int64](1), - Max: utils.NewT[int64](14), - PreserveOriginal: utils.NewT(false), - StartMarker: utils.NewT("^"), - EndMarker: utils.NewT("^"), - StreamType: utils.NewT(arangodb.ArangoSearchNGramStreamUTF8), + Min: utils.NewType[int64](1), + Max: utils.NewType[int64](14), + PreserveOriginal: utils.NewType(false), + StartMarker: utils.NewType("^"), + EndMarker: utils.NewType("^"), + StreamType: utils.NewType(arangodb.ArangoSearchNGramStreamUTF8), }, }, }, @@ -164,11 +164,11 @@ func Test_Analyzers(t *testing.T) { Type: arangodb.ArangoSearchAnalyzerTypeAQL, Properties: arangodb.ArangoSearchAnalyzerProperties{ QueryString: `FOR year IN [ 2011, 2012, 2013 ] FOR quarter IN [ 1, 2, 3, 4 ] RETURN { year, quarter, formatted: CONCAT(quarter, " / ", year)}`, - CollapsePositions: utils.NewT(true), - KeepNull: utils.NewT(false), - BatchSize: utils.NewT(10), + CollapsePositions: utils.NewType(true), + KeepNull: utils.NewType(false), + BatchSize: utils.NewType(10), ReturnType: arangodb.ArangoSearchAnalyzerAQLReturnTypeString.New(), - MemoryLimit: utils.NewT(1024 * 1024), + MemoryLimit: utils.NewType(1024 * 1024), }, }, }, @@ -180,9 +180,9 @@ func Test_Analyzers(t *testing.T) { Type: arangodb.ArangoSearchAnalyzerTypeGeoPoint, Properties: arangodb.ArangoSearchAnalyzerProperties{ Options: &arangodb.ArangoSearchAnalyzerGeoOptions{ - MaxCells: utils.NewT(20), - MinLevel: utils.NewT(4), - MaxLevel: utils.NewT(23), + MaxCells: utils.NewType(20), + MinLevel: utils.NewType(4), + MaxLevel: utils.NewType(23), }, Latitude: []string{}, Longitude: []string{}, @@ -197,9 +197,9 @@ func Test_Analyzers(t *testing.T) { Type: arangodb.ArangoSearchAnalyzerTypeGeoJSON, Properties: arangodb.ArangoSearchAnalyzerProperties{ Options: &arangodb.ArangoSearchAnalyzerGeoOptions{ - MaxCells: utils.NewT(20), - MinLevel: utils.NewT(4), - MaxLevel: utils.NewT(23), + MaxCells: utils.NewType(20), + MinLevel: utils.NewType(4), + MaxLevel: utils.NewType(23), }, Type: arangodb.ArangoSearchAnalyzerGeoJSONTypeShape.New(), }, @@ -212,11 +212,11 @@ func Test_Analyzers(t *testing.T) { Name: "my-geo_s2", Type: arangodb.ArangoSearchAnalyzerTypeGeoS2, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Format: utils.NewT(arangodb.ArangoSearchFormatLatLngInt), + Format: utils.NewType(arangodb.ArangoSearchFormatLatLngInt), Options: &arangodb.ArangoSearchAnalyzerGeoOptions{ - MaxCells: utils.NewT(20), - MinLevel: utils.NewT(4), - MaxLevel: utils.NewT(23), + MaxCells: utils.NewType(20), + MinLevel: utils.NewType(4), + MaxLevel: utils.NewType(23), }, Type: arangodb.ArangoSearchAnalyzerGeoJSONTypeShape.New(), }, @@ -225,11 +225,11 @@ func Test_Analyzers(t *testing.T) { Name: "my-geo_s2", Type: arangodb.ArangoSearchAnalyzerTypeGeoS2, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Format: utils.NewT(arangodb.ArangoSearchFormatLatLngInt), + Format: utils.NewType(arangodb.ArangoSearchFormatLatLngInt), Options: &arangodb.ArangoSearchAnalyzerGeoOptions{ - MaxCells: utils.NewT(20), - MinLevel: utils.NewT(4), - MaxLevel: utils.NewT(23), + MaxCells: utils.NewType(20), + MinLevel: utils.NewType(4), + MaxLevel: utils.NewType(23), }, Type: arangodb.ArangoSearchAnalyzerGeoJSONTypeShape.New(), }, @@ -273,7 +273,7 @@ func Test_Analyzers(t *testing.T) { Name: "my-stopWords", Type: arangodb.ArangoSearchAnalyzerTypeStopwords, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Hex: utils.NewT(true), + Hex: utils.NewType(true), Stopwords: []string{ "616e64", "746865", @@ -284,7 +284,7 @@ func Test_Analyzers(t *testing.T) { Name: "my-stopWords", Type: arangodb.ArangoSearchAnalyzerTypeStopwords, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Hex: utils.NewT(true), + Hex: utils.NewType(true), Stopwords: []string{ "616e64", "746865", @@ -303,14 +303,14 @@ func Test_Analyzers(t *testing.T) { Analyzer: &arangodb.AnalyzerDefinition{ Type: arangodb.ArangoSearchAnalyzerTypeStopwords, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Hex: utils.NewT(true), + Hex: utils.NewType(true), Stopwords: []string{ "616e64", "746865", }, }, }, - NumHashes: utils.NewT[uint64](2), + NumHashes: utils.NewType[uint64](2), }, }, ExpectedDefinition: &arangodb.AnalyzerDefinition{ @@ -320,14 +320,14 @@ func Test_Analyzers(t *testing.T) { Analyzer: &arangodb.AnalyzerDefinition{ Type: arangodb.ArangoSearchAnalyzerTypeStopwords, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Hex: utils.NewT(true), + Hex: utils.NewType(true), Stopwords: []string{ "616e64", "746865", }, }, }, - NumHashes: utils.NewT[uint64](2), + NumHashes: utils.NewType[uint64](2), }, }, }, diff --git a/v2/tests/database_collection_doc_create_test.go b/v2/tests/database_collection_doc_create_test.go index d3b0f462..8e8bd06a 100644 --- a/v2/tests/database_collection_doc_create_test.go +++ b/v2/tests/database_collection_doc_create_test.go @@ -113,7 +113,7 @@ func Test_DatabaseCollectionDocCreateOverwrite(t *testing.T) { metaReplacedSimple, err := col.CreateDocumentWithOptions(ctx, docOverwrite, &arangodb.CollectionDocumentCreateOptions{ OldObject: &oldDoc, NewObject: &newDoc, - Overwrite: utils.NewT(true), + Overwrite: utils.NewType(true), }) require.NoError(t, err) require.NotEqual(t, metaReplacedSimple.Rev, metaReplaced.Rev) @@ -134,7 +134,7 @@ func Test_DatabaseCollectionDocCreateKeepNull(t *testing.T) { doc := DocWithRev{ Name: "test-keep-null", - Age: utils.NewT(10), + Age: utils.NewType(10), } meta, err := col.CreateDocument(ctx, doc) @@ -150,7 +150,7 @@ func Test_DatabaseCollectionDocCreateKeepNull(t *testing.T) { overwriteMode := arangodb.CollectionDocumentCreateOverwriteModeUpdate metaUpdated, err := col.CreateDocumentWithOptions(ctx, docOverwrite, &arangodb.CollectionDocumentCreateOptions{ - KeepNull: utils.NewT(true), + KeepNull: utils.NewType(true), OverwriteMode: overwriteMode.New(), }) require.NoError(t, err) @@ -176,7 +176,7 @@ func Test_DatabaseCollectionDocCreateKeepNull(t *testing.T) { overwriteMode := arangodb.CollectionDocumentCreateOverwriteModeUpdate metaUpdated, err := col.CreateDocumentWithOptions(ctx, docOverwrite, &arangodb.CollectionDocumentCreateOptions{ - KeepNull: utils.NewT(false), + KeepNull: utils.NewType(false), OverwriteMode: overwriteMode.New(), }) require.NoError(t, err) @@ -225,7 +225,7 @@ func Test_DatabaseCollectionDocCreateMergeObjects(t *testing.T) { overwriteMode := arangodb.CollectionDocumentCreateOverwriteModeUpdate metaUpdated, err := col.CreateDocumentWithOptions(ctx, docOverwrite, &arangodb.CollectionDocumentCreateOptions{ - MergeObjects: utils.NewT(true), + MergeObjects: utils.NewType(true), OverwriteMode: overwriteMode.New(), }) require.NoError(t, err) @@ -255,7 +255,7 @@ func Test_DatabaseCollectionDocCreateMergeObjects(t *testing.T) { overwriteMode := arangodb.CollectionDocumentCreateOverwriteModeUpdate metaUpdated, err := col.CreateDocumentWithOptions(ctx, docOverwrite, &arangodb.CollectionDocumentCreateOptions{ - MergeObjects: utils.NewT(false), + MergeObjects: utils.NewType(false), OverwriteMode: overwriteMode.New(), }) require.NoError(t, err) @@ -287,11 +287,11 @@ func Test_DatabaseCollectionDocCreateSilent(t *testing.T) { doc := DocWithRev{ Name: "test-silent", - Age: utils.NewT(42), + Age: utils.NewType(42), } meta, err := col.CreateDocumentWithOptions(ctx, doc, &arangodb.CollectionDocumentCreateOptions{ - Silent: utils.NewT(true), + Silent: utils.NewType(true), }) require.NoError(t, err) require.Empty(t, meta.Key, "response should be empty (silent)!") @@ -308,12 +308,12 @@ func Test_DatabaseCollectionDocCreateWaitForSync(t *testing.T) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { doc := DocWithRev{ Name: "test-wait-for-sync", - Age: utils.NewT(23), + Age: utils.NewType(23), } t.Run("WithWaitForSync==false should not return an error", func(t *testing.T) { meta, err := col.CreateDocumentWithOptions(ctx, doc, &arangodb.CollectionDocumentCreateOptions{ - WithWaitForSync: utils.NewT(false), + WithWaitForSync: utils.NewType(false), }) require.NoError(t, err) require.NotEmpty(t, meta.Key) @@ -321,7 +321,7 @@ func Test_DatabaseCollectionDocCreateWaitForSync(t *testing.T) { t.Run("WithWaitForSync==true should not return an error", func(t *testing.T) { meta, err := col.CreateDocumentWithOptions(ctx, doc, &arangodb.CollectionDocumentCreateOptions{ - WithWaitForSync: utils.NewT(true), + WithWaitForSync: utils.NewType(true), }) require.NoError(t, err) require.NotEmpty(t, meta.Key) @@ -341,7 +341,7 @@ func Test_DatabaseCollectionDocCreateReplaceWithVersionAttribute(t *testing.T) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { doc := DocWithRev{ Name: "test-version-attribute", - Age: utils.NewT(23), + Age: utils.NewType(23), } meta, err := col.CreateDocument(ctx, doc) @@ -353,14 +353,14 @@ func Test_DatabaseCollectionDocCreateReplaceWithVersionAttribute(t *testing.T) { docReplaced := DocWithRev{ Name: "test-check-Replaced", - Age: utils.NewT(19), + Age: utils.NewType(19), Key: meta.Key, } metaDoc, err := col.CreateDocumentWithOptions(ctx, docReplaced, &arangodb.CollectionDocumentCreateOptions{ NewObject: &newDoc, OldObject: &oldDoc, - Overwrite: utils.NewT(true), + Overwrite: utils.NewType(true), VersionAttribute: "age", }) require.NoError(t, err) @@ -377,14 +377,14 @@ func Test_DatabaseCollectionDocCreateReplaceWithVersionAttribute(t *testing.T) { docReplaced := DocWithRev{ Name: "test-check-Replaced", - Age: utils.NewT(99), + Age: utils.NewType(99), Key: meta.Key, } metaDoc, err := col.CreateDocumentWithOptions(ctx, docReplaced, &arangodb.CollectionDocumentCreateOptions{ NewObject: &newDoc, OldObject: &oldDoc, - Overwrite: utils.NewT(true), + Overwrite: utils.NewType(true), VersionAttribute: "age", }) require.NoError(t, err) diff --git a/v2/tests/database_collection_doc_delete_test.go b/v2/tests/database_collection_doc_delete_test.go index a031298a..5696473b 100644 --- a/v2/tests/database_collection_doc_delete_test.go +++ b/v2/tests/database_collection_doc_delete_test.go @@ -223,7 +223,7 @@ func Test_DatabaseCollectionDocDeleteIgnoreRevs(t *testing.T) { } delReader, err := col.DeleteDocumentsWithOptions(ctx, docToRemove, &arangodb.CollectionDocumentDeleteOptions{ - IgnoreRevs: utils.NewT(false), + IgnoreRevs: utils.NewType(false), }) require.NoError(t, err) @@ -245,7 +245,7 @@ func Test_DatabaseCollectionDocDeleteIgnoreRevs(t *testing.T) { } delReader, err := col.DeleteDocumentsWithOptions(ctx, docToRemove, &arangodb.CollectionDocumentDeleteOptions{ - IgnoreRevs: utils.NewT(false), + IgnoreRevs: utils.NewType(false), }) require.NoError(t, err) @@ -268,7 +268,7 @@ func Test_DatabaseCollectionDocDeleteIgnoreRevs(t *testing.T) { } delReader, err := col.DeleteDocumentsWithOptions(ctx, docToRemove, &arangodb.CollectionDocumentDeleteOptions{ - IgnoreRevs: utils.NewT(false), + IgnoreRevs: utils.NewType(false), }) require.NoError(t, err) @@ -298,13 +298,13 @@ func Test_DatabaseCollectionDocDeleteSilent(t *testing.T) { doc := DocWithRev{ Name: "test-silent", - Age: utils.NewT(42), + Age: utils.NewType(42), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) metaDeleted, err := col.DeleteDocumentWithOptions(ctx, meta.Key, &arangodb.CollectionDocumentDeleteOptions{ - Silent: utils.NewT(true), + Silent: utils.NewType(true), }) require.NoError(t, err) require.Empty(t, metaDeleted.Key, "response should be empty (silent)!") @@ -322,13 +322,13 @@ func Test_DatabaseCollectionDocDeleteWaitForSync(t *testing.T) { t.Run("WithWaitForSync==false should not return an error", func(t *testing.T) { doc := DocWithRev{ Name: "test-wait-for-sync-false", - Age: utils.NewT(23), + Age: utils.NewType(23), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) metaDel, err := col.DeleteDocumentWithOptions(ctx, meta.Key, &arangodb.CollectionDocumentDeleteOptions{ - WithWaitForSync: utils.NewT(false), + WithWaitForSync: utils.NewType(false), }) require.NoError(t, err) require.NotEmpty(t, metaDel.Key) @@ -337,13 +337,13 @@ func Test_DatabaseCollectionDocDeleteWaitForSync(t *testing.T) { t.Run("WithWaitForSync==true should not return an error", func(t *testing.T) { doc := DocWithRev{ Name: "test-wait-for-sync-true", - Age: utils.NewT(23), + Age: utils.NewType(23), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) metaDel, err := col.DeleteDocumentWithOptions(ctx, meta.Key, &arangodb.CollectionDocumentDeleteOptions{ - WithWaitForSync: utils.NewT(true), + WithWaitForSync: utils.NewType(true), }) require.NoError(t, err) require.NotEmpty(t, metaDel.Key) diff --git a/v2/tests/database_collection_doc_read_test.go b/v2/tests/database_collection_doc_read_test.go index 8ef82bde..308c5d3e 100644 --- a/v2/tests/database_collection_doc_read_test.go +++ b/v2/tests/database_collection_doc_read_test.go @@ -109,7 +109,7 @@ func Test_DatabaseCollectionDocReadIgnoreRevs(t *testing.T) { } r, err := col.ReadDocumentsWithOptions(ctx, &docToRead, &arangodb.CollectionDocumentReadOptions{ - IgnoreRevs: utils.NewT(false), + IgnoreRevs: utils.NewType(false), }) require.NoError(t, err) @@ -129,7 +129,7 @@ func Test_DatabaseCollectionDocReadIgnoreRevs(t *testing.T) { } r, err := col.ReadDocumentsWithOptions(ctx, &docToRead, &arangodb.CollectionDocumentReadOptions{ - IgnoreRevs: utils.NewT(false), + IgnoreRevs: utils.NewType(false), }) require.NoError(t, err) @@ -146,7 +146,7 @@ func Test_DatabaseCollectionDocReadIgnoreRevs(t *testing.T) { } r, err := col.ReadDocumentsWithOptions(ctx, &docToRead, &arangodb.CollectionDocumentReadOptions{ - IgnoreRevs: utils.NewT(false), + IgnoreRevs: utils.NewType(false), }) require.NoError(t, err) @@ -168,7 +168,7 @@ func Test_DatabaseCollectionDocReadAllowDirtyReads(t *testing.T) { t.Run("WithWaitForSync==false should not return an error", func(t *testing.T) { doc := DocWithRev{ Name: "test-wait-for-sync-false", - Age: utils.NewT(23), + Age: utils.NewType(23), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) diff --git a/v2/tests/database_collection_doc_replace_test.go b/v2/tests/database_collection_doc_replace_test.go index e653c92c..280785a0 100644 --- a/v2/tests/database_collection_doc_replace_test.go +++ b/v2/tests/database_collection_doc_replace_test.go @@ -95,7 +95,7 @@ func Test_DatabaseCollectionDocReplaceIgnoreRevs(t *testing.T) { t.Run("do not replace if rev doesn't match", func(t *testing.T) { docReplace.Rev = "wrong-rev" metaError, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, docReplace, &arangodb.CollectionDocumentReplaceOptions{ - IgnoreRevs: utils.NewT(false), + IgnoreRevs: utils.NewType(false), }) require.Error(t, err) require.Empty(t, metaError.Rev) @@ -104,7 +104,7 @@ func Test_DatabaseCollectionDocReplaceIgnoreRevs(t *testing.T) { t.Run("do an update if rev match", func(t *testing.T) { docReplace.Rev = meta.Rev metaReplaced, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, docReplace, &arangodb.CollectionDocumentReplaceOptions{ - IgnoreRevs: utils.NewT(false), + IgnoreRevs: utils.NewType(false), }) require.NoError(t, err) require.NotEmpty(t, metaReplaced.Rev) @@ -114,7 +114,7 @@ func Test_DatabaseCollectionDocReplaceIgnoreRevs(t *testing.T) { t.Run("do an update if rev is missing", func(t *testing.T) { docReplace.Rev = "" metaReplaced, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, docReplace, &arangodb.CollectionDocumentReplaceOptions{ - IgnoreRevs: utils.NewT(false), + IgnoreRevs: utils.NewType(false), }) require.NoError(t, err) require.NotEmpty(t, metaReplaced.Rev) @@ -135,7 +135,7 @@ func Test_DatabaseCollectionDocReplaceSilent(t *testing.T) { doc := DocWithRev{ Name: "test-silent", - Age: utils.NewT(42), + Age: utils.NewType(42), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) @@ -144,7 +144,7 @@ func Test_DatabaseCollectionDocReplaceSilent(t *testing.T) { Name: "test-silent-updated", } metaUpdated, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, docReplace, &arangodb.CollectionDocumentReplaceOptions{ - Silent: utils.NewT(true), + Silent: utils.NewType(true), }) require.NoError(t, err) require.Empty(t, metaUpdated.Key, "response should be empty (silent)!") @@ -161,24 +161,24 @@ func Test_DatabaseCollectionDocReplaceWaitForSync(t *testing.T) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { doc := DocWithRev{ Name: "test-wait-for-sync", - Age: utils.NewT(23), + Age: utils.NewType(23), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) t.Run("WithWaitForSync==false should not return an error", func(t *testing.T) { - doc.Age = utils.NewT(42) + doc.Age = utils.NewType(42) meta, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, doc, &arangodb.CollectionDocumentReplaceOptions{ - WithWaitForSync: utils.NewT(false), + WithWaitForSync: utils.NewType(false), }) require.NoError(t, err) require.NotEmpty(t, meta.Key) }) t.Run("WithWaitForSync==true should not return an error", func(t *testing.T) { - doc.Age = utils.NewT(32) + doc.Age = utils.NewType(32) meta, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, doc, &arangodb.CollectionDocumentReplaceOptions{ - WithWaitForSync: utils.NewT(true), + WithWaitForSync: utils.NewType(true), }) require.NoError(t, err) require.NotEmpty(t, meta.Key) @@ -198,7 +198,7 @@ func Test_DatabaseCollectionDocReplaceVersionAttribute(t *testing.T) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { doc := DocWithRev{ Name: "test-version-attribute", - Age: utils.NewT(23), + Age: utils.NewType(23), } meta, err := col.CreateDocument(ctx, doc) @@ -210,7 +210,7 @@ func Test_DatabaseCollectionDocReplaceVersionAttribute(t *testing.T) { docReplaced := DocWithRev{ Name: "test-check-Replaced", - Age: utils.NewT(19), + Age: utils.NewType(19), } metaDoc, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, docReplaced, &arangodb.CollectionDocumentReplaceOptions{ @@ -232,7 +232,7 @@ func Test_DatabaseCollectionDocReplaceVersionAttribute(t *testing.T) { docReplaced := DocWithRev{ Name: "test-check-Replaced", - Age: utils.NewT(99), + Age: utils.NewType(99), } metaDoc, err := col.ReplaceDocumentWithOptions(ctx, meta.Key, docReplaced, &arangodb.CollectionDocumentReplaceOptions{ diff --git a/v2/tests/database_collection_doc_update_test.go b/v2/tests/database_collection_doc_update_test.go index dce447b0..8771db4d 100644 --- a/v2/tests/database_collection_doc_update_test.go +++ b/v2/tests/database_collection_doc_update_test.go @@ -95,7 +95,7 @@ func Test_DatabaseCollectionDocUpdateIgnoreRevs(t *testing.T) { t.Run("do not update if rev doesn't match", func(t *testing.T) { docUpdate.Rev = "wrong-rev" metaError, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docUpdate, &arangodb.CollectionDocumentUpdateOptions{ - IgnoreRevs: utils.NewT(false), + IgnoreRevs: utils.NewType(false), }) require.Error(t, err) require.Empty(t, metaError.Rev) @@ -104,7 +104,7 @@ func Test_DatabaseCollectionDocUpdateIgnoreRevs(t *testing.T) { t.Run("do an update if rev match", func(t *testing.T) { docUpdate.Rev = meta.Rev metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docUpdate, &arangodb.CollectionDocumentUpdateOptions{ - IgnoreRevs: utils.NewT(false), + IgnoreRevs: utils.NewType(false), }) require.NoError(t, err) require.NotEmpty(t, metaUpdated.Rev) @@ -114,7 +114,7 @@ func Test_DatabaseCollectionDocUpdateIgnoreRevs(t *testing.T) { t.Run("do an update if rev is missing", func(t *testing.T) { docUpdate.Rev = "" metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docUpdate, &arangodb.CollectionDocumentUpdateOptions{ - IgnoreRevs: utils.NewT(false), + IgnoreRevs: utils.NewType(false), }) require.NoError(t, err) require.NotEmpty(t, metaUpdated.Rev) @@ -134,7 +134,7 @@ func Test_DatabaseCollectionDocUpdateKeepNull(t *testing.T) { doc := DocWithRev{ Name: "test-keep-null", - Age: utils.NewT(10), + Age: utils.NewType(10), } meta, err := col.CreateDocument(ctx, doc) @@ -149,7 +149,7 @@ func Test_DatabaseCollectionDocUpdateKeepNull(t *testing.T) { } metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docOverwrite, &arangodb.CollectionDocumentUpdateOptions{ - KeepNull: utils.NewT(true), + KeepNull: utils.NewType(true), }) require.NoError(t, err) require.Equal(t, metaUpdated.Key, meta.Key) @@ -173,7 +173,7 @@ func Test_DatabaseCollectionDocUpdateKeepNull(t *testing.T) { } metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docOverwrite, &arangodb.CollectionDocumentUpdateOptions{ - KeepNull: utils.NewT(false), + KeepNull: utils.NewType(false), }) require.NoError(t, err) require.Equal(t, metaUpdated.Key, meta.Key) @@ -220,7 +220,7 @@ func Test_DatabaseCollectionDocUpdateMergeObjects(t *testing.T) { } metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docOverwrite, &arangodb.CollectionDocumentUpdateOptions{ - MergeObjects: utils.NewT(true), + MergeObjects: utils.NewType(true), }) require.NoError(t, err) require.Equal(t, metaUpdated.Key, meta.Key) @@ -248,7 +248,7 @@ func Test_DatabaseCollectionDocUpdateMergeObjects(t *testing.T) { } metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docOverwrite, &arangodb.CollectionDocumentUpdateOptions{ - MergeObjects: utils.NewT(false), + MergeObjects: utils.NewType(false), }) require.NoError(t, err) require.Equal(t, metaUpdated.Key, meta.Key) @@ -279,7 +279,7 @@ func Test_DatabaseCollectionDocUpdateSilent(t *testing.T) { doc := DocWithRev{ Name: "test-silent", - Age: utils.NewT(42), + Age: utils.NewType(42), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) @@ -288,7 +288,7 @@ func Test_DatabaseCollectionDocUpdateSilent(t *testing.T) { Name: "test-silent-updated", } metaUpdated, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docUpdate, &arangodb.CollectionDocumentUpdateOptions{ - Silent: utils.NewT(true), + Silent: utils.NewType(true), }) require.NoError(t, err) require.Empty(t, metaUpdated.Key, "response should be empty (silent)!") @@ -305,24 +305,24 @@ func Test_DatabaseCollectionDocUpdateWaitForSync(t *testing.T) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { doc := DocWithRev{ Name: "test-wait-for-sync", - Age: utils.NewT(23), + Age: utils.NewType(23), } meta, err := col.CreateDocument(ctx, doc) require.NoError(t, err) t.Run("WithWaitForSync==false should not return an error", func(t *testing.T) { - doc.Age = utils.NewT(42) + doc.Age = utils.NewType(42) meta, err := col.UpdateDocumentWithOptions(ctx, meta.Key, doc, &arangodb.CollectionDocumentUpdateOptions{ - WithWaitForSync: utils.NewT(false), + WithWaitForSync: utils.NewType(false), }) require.NoError(t, err) require.NotEmpty(t, meta.Key) }) t.Run("WithWaitForSync==true should not return an error", func(t *testing.T) { - doc.Age = utils.NewT(32) + doc.Age = utils.NewType(32) meta, err := col.UpdateDocumentWithOptions(ctx, meta.Key, doc, &arangodb.CollectionDocumentUpdateOptions{ - WithWaitForSync: utils.NewT(true), + WithWaitForSync: utils.NewType(true), }) require.NoError(t, err) require.NotEmpty(t, meta.Key) @@ -342,7 +342,7 @@ func Test_DatabaseCollectionDocUpdateVersionAttribute(t *testing.T) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { doc := DocWithRev{ Name: "test-version-attribute", - Age: utils.NewT(23), + Age: utils.NewType(23), } meta, err := col.CreateDocument(ctx, doc) @@ -354,7 +354,7 @@ func Test_DatabaseCollectionDocUpdateVersionAttribute(t *testing.T) { docUpdate := DocWithRev{ Name: "test-check-UPDATED", - Age: utils.NewT(19), + Age: utils.NewType(19), } metaDoc, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docUpdate, &arangodb.CollectionDocumentUpdateOptions{ @@ -376,7 +376,7 @@ func Test_DatabaseCollectionDocUpdateVersionAttribute(t *testing.T) { docUpdate := DocWithRev{ Name: "test-check-UPDATED", - Age: utils.NewT(99), + Age: utils.NewType(99), } metaDoc, err := col.UpdateDocumentWithOptions(ctx, meta.Key, docUpdate, &arangodb.CollectionDocumentUpdateOptions{ diff --git a/v2/tests/database_collection_indexes_test.go b/v2/tests/database_collection_indexes_test.go index 149f2f1c..3bff8a10 100644 --- a/v2/tests/database_collection_indexes_test.go +++ b/v2/tests/database_collection_indexes_test.go @@ -90,23 +90,23 @@ func Test_EnsurePersistentIndex(t *testing.T) { {true, 2, []string{"age", "name"}, nil}, // same as default {false, 2, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(false), Sparse: utils.NewT(false)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewType(false), Sparse: utils.NewType(false)}}, // unique {true, 3, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(true), Sparse: utils.NewT(false)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewType(true), Sparse: utils.NewType(false)}}, {false, 3, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(true), Sparse: utils.NewT(false)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewType(true), Sparse: utils.NewType(false)}}, {true, 4, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(true), Sparse: utils.NewT(true)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewType(true), Sparse: utils.NewType(true)}}, {false, 4, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(true), Sparse: utils.NewT(true)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewType(true), Sparse: utils.NewType(true)}}, {true, 5, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(false), Sparse: utils.NewT(true)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewType(false), Sparse: utils.NewType(true)}}, {false, 5, []string{"age", "name"}, - &arangodb.CreatePersistentIndexOptions{Unique: utils.NewT(false), Sparse: utils.NewT(true)}}, + &arangodb.CreatePersistentIndexOptions{Unique: utils.NewType(false), Sparse: utils.NewType(true)}}, } for _, testOpt := range testOptions { @@ -140,7 +140,7 @@ func Test_EnsurePersistentIndex(t *testing.T) { options := &arangodb.CreatePersistentIndexOptions{ StoredValues: storedValues, - CacheEnabled: utils.NewT(true), + CacheEnabled: utils.NewType(true), } idx, created, err := col.EnsurePersistentIndex(ctx, fields, options) @@ -171,9 +171,9 @@ func Test_EnsurePersistentIndexDeduplicate(t *testing.T) { t.Run("Create index with Deduplicate OFF", func(t *testing.T) { idx, created, err := col.EnsurePersistentIndex(ctx, []string{"tags[*]"}, &arangodb.CreatePersistentIndexOptions{ - Deduplicate: utils.NewT(false), - Unique: utils.NewT(true), - Sparse: utils.NewT(false), + Deduplicate: utils.NewType(false), + Unique: utils.NewType(true), + Sparse: utils.NewType(false), }) require.NoError(t, err) require.True(t, created) @@ -190,9 +190,9 @@ func Test_EnsurePersistentIndexDeduplicate(t *testing.T) { t.Run("Create index with Deduplicate ON", func(t *testing.T) { idx, created, err := col.EnsurePersistentIndex(ctx, []string{"tags[*]"}, &arangodb.CreatePersistentIndexOptions{ - Deduplicate: utils.NewT(true), - Unique: utils.NewT(true), - Sparse: utils.NewT(false), + Deduplicate: utils.NewType(true), + Unique: utils.NewType(true), + Sparse: utils.NewType(false), }) require.NoError(t, err) require.True(t, created) @@ -301,8 +301,8 @@ func Test_EnsureGeoIndexIndex(t *testing.T) { t.Run("Test GeoJSON opts", func(t *testing.T) { var testOptions = []arangodb.CreateGeoIndexOptions{ - {GeoJSON: utils.NewT(true)}, - {GeoJSON: utils.NewT(false)}, + {GeoJSON: utils.NewType(true)}, + {GeoJSON: utils.NewType(false)}, } for _, testOpt := range testOptions { idx, created, err := col.EnsureGeoIndex(ctx, []string{"geo"}, &testOpt) @@ -325,25 +325,25 @@ func Test_EnsureGeoIndexIndex(t *testing.T) { true, false, []string{"geoOld1"}, - &arangodb.CreateGeoIndexOptions{LegacyPolygons: utils.NewT(true)}, + &arangodb.CreateGeoIndexOptions{LegacyPolygons: utils.NewType(true)}, }, { false, false, []string{"geoOld2"}, - &arangodb.CreateGeoIndexOptions{LegacyPolygons: utils.NewT(false)}, + &arangodb.CreateGeoIndexOptions{LegacyPolygons: utils.NewType(false)}, }, { false, true, []string{"geoOld3"}, - &arangodb.CreateGeoIndexOptions{GeoJSON: utils.NewT(true), LegacyPolygons: utils.NewT(false)}, + &arangodb.CreateGeoIndexOptions{GeoJSON: utils.NewType(true), LegacyPolygons: utils.NewType(false)}, }, { false, false, []string{"geoOld4"}, - &arangodb.CreateGeoIndexOptions{GeoJSON: utils.NewT(false), LegacyPolygons: utils.NewT(false)}, + &arangodb.CreateGeoIndexOptions{GeoJSON: utils.NewType(false), LegacyPolygons: utils.NewType(false)}, }, } diff --git a/v2/tests/database_collection_operations_test.go b/v2/tests/database_collection_operations_test.go index 2ca627fe..eb096eb1 100644 --- a/v2/tests/database_collection_operations_test.go +++ b/v2/tests/database_collection_operations_test.go @@ -115,7 +115,7 @@ func Test_CollectionSetProperties(t *testing.T) { ReplicationFactor: 2, JournalSize: 1048576 * 2, NumberOfShards: 2, - CacheEnabled: utils.NewT(false), + CacheEnabled: utils.NewType(false), } Wrap(t, func(t *testing.T, client arangodb.Client) { @@ -135,10 +135,10 @@ func Test_CollectionSetProperties(t *testing.T) { }) newProps := arangodb.SetCollectionPropertiesOptions{ - WaitForSync: utils.NewT(true), + WaitForSync: utils.NewType(true), ReplicationFactor: 3, WriteConcern: 2, - CacheEnabled: utils.NewT(true), + CacheEnabled: utils.NewType(true), Schema: nil, } err = col.SetProperties(ctx, newProps) @@ -202,7 +202,7 @@ func Test_WithQueryOptimizerRules(t *testing.T) { defer c() col, err := db.CreateCollectionWithOptions(ctx, "test", nil, &arangodb.CreateCollectionOptions{ - EnforceReplicationFactor: utils.NewT(false), + EnforceReplicationFactor: utils.NewType(false), }) require.NoError(t, err) diff --git a/v2/tests/database_collection_perf_test.go b/v2/tests/database_collection_perf_test.go index 548fdd4a..b434fa40 100644 --- a/v2/tests/database_collection_perf_test.go +++ b/v2/tests/database_collection_perf_test.go @@ -44,7 +44,7 @@ func insertDocuments(t testing.TB, col arangodb.Collection, documents, batch int if len(b) == batch { insertBatch(t, context.Background(), col, &arangodb.CollectionDocumentCreateOptions{ - WithWaitForSync: utils.NewT(true), + WithWaitForSync: utils.NewType(true), }, b) b = b[:0] } diff --git a/v2/tests/database_view-arangosearch-simple_test.go b/v2/tests/database_view-arangosearch-simple_test.go index ce98c318..cb88a82c 100644 --- a/v2/tests/database_view-arangosearch-simple_test.go +++ b/v2/tests/database_view-arangosearch-simple_test.go @@ -38,8 +38,8 @@ func Test_ArangoSearchSimple(t *testing.T) { viewName := GenerateUUID("test-view") opts := &arangodb.ArangoSearchViewProperties{ - CleanupIntervalStep: utils.NewT[int64](1), - CommitInterval: utils.NewT[int64](500), + CleanupIntervalStep: utils.NewType[int64](1), + CommitInterval: utils.NewType[int64](500), } view, err := db.CreateArangoSearchView(ctx, viewName, opts) @@ -54,7 +54,7 @@ func Test_ArangoSearchSimple(t *testing.T) { t.Run("Update properties of the view", func(t *testing.T) { opt := arangodb.ArangoSearchViewProperties{ - CommitInterval: utils.NewT[int64](200), + CommitInterval: utils.NewType[int64](200), } err = view.UpdateProperties(ctx, opt) require.NoError(t, err) @@ -69,7 +69,7 @@ func Test_ArangoSearchSimple(t *testing.T) { t.Run("Replace properties of the view", func(t *testing.T) { opt := arangodb.ArangoSearchViewProperties{ - CommitInterval: utils.NewT[int64](300), + CommitInterval: utils.NewType[int64](300), } err = view.SetProperties(ctx, opt) require.NoError(t, err) diff --git a/v2/tests/database_view-arangosearch_test.go b/v2/tests/database_view-arangosearch_test.go index b019c12c..7852a5e5 100644 --- a/v2/tests/database_view-arangosearch_test.go +++ b/v2/tests/database_view-arangosearch_test.go @@ -591,10 +591,10 @@ func Test_UseArangoSearchViewWithPipelineAnalyzer(t *testing.T) { { Type: arangodb.ArangoSearchAnalyzerTypeNGram, Properties: arangodb.ArangoSearchAnalyzerProperties{ - Min: utils.NewT[int64](2), - Max: utils.NewT[int64](2), - PreserveOriginal: utils.NewT(false), - StreamType: utils.NewT(arangodb.ArangoSearchNGramStreamUTF8), + Min: utils.NewType[int64](2), + Max: utils.NewType[int64](2), + PreserveOriginal: utils.NewType(false), + StreamType: utils.NewType(arangodb.ArangoSearchNGramStreamUTF8), }, }, { @@ -685,7 +685,7 @@ func Test_ArangoSearchViewProperties35(t *testing.T) { CommitInterval: &commitInterval, PrimarySort: []arangodb.ArangoSearchPrimarySortEntry{{ Field: sortField, - Ascending: utils.NewT(false), + Ascending: utils.NewType(false), }}, StoredValues: []arangodb.StoredValue{{ Fields: storedValuesFields, @@ -828,8 +828,8 @@ func Test_ArangoSearchViewProperties353(t *testing.T) { }, }, }, - IncludeAllFields: utils.NewT(true), - InBackground: utils.NewT(false), + IncludeAllFields: utils.NewType(true), + InBackground: utils.NewType(false), }, }, } @@ -868,12 +868,12 @@ func Test_ArangoSearchViewLinkAndStoredValueCache(t *testing.T) { StoredValues: []arangodb.StoredValue{ { Fields: []string{"f1", "f2"}, - Cache: utils.NewT(true), + Cache: utils.NewType(true), }, }, Links: arangodb.ArangoSearchLinks{ linkedColName: arangodb.ArangoSearchElementProperties{ - Cache: utils.NewT(false), + Cache: utils.NewType(false), }, }, } @@ -883,13 +883,13 @@ func Test_ArangoSearchViewLinkAndStoredValueCache(t *testing.T) { p, err := v.Properties(ctx) require.NoError(t, err) require.Len(t, p.StoredValues, 1) - require.Equal(t, utils.NewT(true), p.StoredValues[0].Cache) + require.Equal(t, utils.NewType(true), p.StoredValues[0].Cache) linkedColumnProps := p.Links[linkedColName] require.NotNil(t, linkedColumnProps) require.Nil(t, linkedColumnProps.Cache) // update props: set to cached - p.Links[linkedColName] = arangodb.ArangoSearchElementProperties{Cache: utils.NewT(true)} + p.Links[linkedColName] = arangodb.ArangoSearchElementProperties{Cache: utils.NewType(true)} err = v.SetProperties(ctx, p) require.NoError(t, err) @@ -898,7 +898,7 @@ func Test_ArangoSearchViewLinkAndStoredValueCache(t *testing.T) { require.NoError(t, err) linkedColumnProps = p.Links[linkedColName] require.NotNil(t, linkedColumnProps) - require.Equal(t, utils.NewT(true), linkedColumnProps.Cache) + require.Equal(t, utils.NewType(true), linkedColumnProps.Cache) }) }) }) @@ -919,7 +919,7 @@ func Test_ArangoSearchViewInMemoryCache(t *testing.T) { name := "test_create_asview" opts := &arangodb.ArangoSearchViewProperties{ - PrimarySortCache: utils.NewT(true), + PrimarySortCache: utils.NewType(true), } v, err := db.CreateArangoSearchView(ctx, name, opts) require.NoError(t, err) @@ -929,7 +929,7 @@ func Test_ArangoSearchViewInMemoryCache(t *testing.T) { // bug in arangod: the primarySortCache field is not returned in response. Fixed only in 3.9.6+: t.Run("must-be-returned-in-response", func(t *testing.T) { skipBelowVersion(client, ctx, "3.9.6", t) - require.Equal(t, utils.NewT(true), p.PrimarySortCache) + require.Equal(t, utils.NewType(true), p.PrimarySortCache) }) }) @@ -940,14 +940,14 @@ func Test_ArangoSearchViewInMemoryCache(t *testing.T) { name := "test_view_" opts := &arangodb.ArangoSearchViewProperties{ - PrimaryKeyCache: utils.NewT(true), + PrimaryKeyCache: utils.NewType(true), } v, err := db.CreateArangoSearchView(ctx, name, opts) require.NoError(t, err) p, err := v.Properties(ctx) require.NoError(t, err) - require.Equal(t, utils.NewT(true), p.PrimaryKeyCache) + require.Equal(t, utils.NewType(true), p.PrimaryKeyCache) }) }) }) diff --git a/v2/tests/graph_edge_definitions_edges_test.go b/v2/tests/graph_edge_definitions_edges_test.go index 96d22ede..944ff6ad 100644 --- a/v2/tests/graph_edge_definitions_edges_test.go +++ b/v2/tests/graph_edge_definitions_edges_test.go @@ -58,7 +58,7 @@ func Test_EdgeSimple(t *testing.T) { t.Run("Create Edge", func(t *testing.T) { opts := arangodb.CreateEdgeOptions{ - WaitForSync: utils.NewT(true), + WaitForSync: utils.NewType(true), } createEdgeResp, err := edgeDefResp.Edge.CreateEdge(ctx, doc, &opts) require.NoError(t, err) @@ -85,7 +85,7 @@ func Test_EdgeSimple(t *testing.T) { t.Run("Update Edge", func(t *testing.T) { opts := arangodb.EdgeUpdateOptions{ - WaitForSync: utils.NewT(true), + WaitForSync: utils.NewType(true), } updateEdgeResp, err := edgeDefResp.Edge.UpdateEdge(ctx, docKey, map[string]int{"distance": 10}, &opts) require.NoError(t, err) @@ -105,7 +105,7 @@ func Test_EdgeSimple(t *testing.T) { t.Run("Replace Edge", func(t *testing.T) { opts := arangodb.EdgeReplaceOptions{ - WaitForSync: utils.NewT(true), + WaitForSync: utils.NewType(true), } docReplace := RouteEdge{ @@ -169,7 +169,7 @@ func Test_EdgeExtended(t *testing.T) { t.Run("Create Edge", func(t *testing.T) { var newObject RouteEdge opts := arangodb.CreateEdgeOptions{ - WaitForSync: utils.NewT(true), + WaitForSync: utils.NewType(true), NewObject: &newObject, } @@ -203,7 +203,7 @@ func Test_EdgeExtended(t *testing.T) { t.Run("Update Edge", func(t *testing.T) { var oldObject RouteEdge opts := arangodb.EdgeUpdateOptions{ - WaitForSync: utils.NewT(true), + WaitForSync: utils.NewType(true), OldObject: &oldObject, } updateEdgeResp, err := edgeDefResp.Edge.UpdateEdge(ctx, docKey, map[string]int{"distance": 10}, &opts) @@ -230,7 +230,7 @@ func Test_EdgeExtended(t *testing.T) { opts := arangodb.EdgeReplaceOptions{ OldObject: &oldObject, NewObject: &newObject, - WaitForSync: utils.NewT(true), + WaitForSync: utils.NewType(true), } docReplace := RouteEdge{ diff --git a/v2/tests/graph_edge_definitions_test.go b/v2/tests/graph_edge_definitions_test.go index 6e64d1f4..ed65f3a2 100644 --- a/v2/tests/graph_edge_definitions_test.go +++ b/v2/tests/graph_edge_definitions_test.go @@ -129,7 +129,7 @@ func TestGraphEdgeDefinitionsRemovalCollections(t *testing.T) { edgeDef := gDef.EdgeDefinitions[0] opts := arangodb.DeleteEdgeDefinitionOptions{ - DropCollection: utils.NewT(true), + DropCollection: utils.NewType(true), } delResp, err := graph.DeleteEdgeDefinition(ctx, edgeDef.Collection, &opts) require.NoError(t, err) diff --git a/v2/tests/graph_helper_test.go b/v2/tests/graph_helper_test.go index ecfdd8ae..03d1a187 100644 --- a/v2/tests/graph_helper_test.go +++ b/v2/tests/graph_helper_test.go @@ -34,7 +34,7 @@ import ( func sampleSmartGraph() *arangodb.GraphDefinition { return &arangodb.GraphDefinition{ - NumberOfShards: utils.NewT(3), + NumberOfShards: utils.NewType(3), SmartGraphAttribute: "key", IsSmart: true, } diff --git a/v2/tests/graph_test.go b/v2/tests/graph_test.go index 6dfd0cc9..7b59597a 100644 --- a/v2/tests/graph_test.go +++ b/v2/tests/graph_test.go @@ -38,7 +38,7 @@ func Test_GraphSimple(t *testing.T) { WithDatabase(t, client, nil, func(db arangodb.Database) { gDef := sampleGraphWithEdges(db) gDef.ReplicationFactor = 2 - gDef.WriteConcern = utils.NewT(2) + gDef.WriteConcern = utils.NewType(2) WithGraph(t, db, gDef, nil, func(graph arangodb.Graph) { withContextT(t, defaultTestTimeout, func(ctx context.Context, tb testing.TB) { exist, err := db.GraphExists(ctx, graph.Name()) @@ -102,7 +102,7 @@ func Test_GraphCreation(t *testing.T) { gDef.ReplicationFactor = arangodb.SatelliteGraph gDef.IsSmart = false gDef.SmartGraphAttribute = "" - gDef.NumberOfShards = utils.NewT(1) + gDef.NumberOfShards = utils.NewType(1) g, err := db.CreateGraph(ctx, db.Name()+"_sat", gDef, nil) require.NoError(t, err) @@ -147,7 +147,7 @@ func Test_GraphCreation(t *testing.T) { From: []string{colNonSat}, }, }, - NumberOfShards: utils.NewT(2), + NumberOfShards: utils.NewType(2), SmartGraphAttribute: "test", IsSmart: true, ReplicationFactor: 2, diff --git a/v2/tests/graph_vertex_collections_test.go b/v2/tests/graph_vertex_collections_test.go index 171ee8a7..04d5964e 100644 --- a/v2/tests/graph_vertex_collections_test.go +++ b/v2/tests/graph_vertex_collections_test.go @@ -114,7 +114,7 @@ func TestCreateSatelliteVertexCollection(t *testing.T) { t.Run("Deleting Vertex should remove the collection when requested", func(t *testing.T) { opts := arangodb.DeleteVertexCollectionOptions{ - DropCollection: utils.NewT(true), + DropCollection: utils.NewType(true), } delResp, err := graph.DeleteVertexCollection(ctx, colName, &opts) require.NoError(t, err) diff --git a/v2/tests/graph_vertex_collections_vertices_test.go b/v2/tests/graph_vertex_collections_vertices_test.go index 333d29d3..7b03d7a5 100644 --- a/v2/tests/graph_vertex_collections_vertices_test.go +++ b/v2/tests/graph_vertex_collections_vertices_test.go @@ -238,7 +238,7 @@ func Test_VerticesUpdate(t *testing.T) { john := Developer{ Name: "John", - IsAdmin: utils.NewT(true), + IsAdmin: utils.NewType(true), } johnResp, err := colVertex.CreateVertex(ctx, john, nil) @@ -251,7 +251,7 @@ func Test_VerticesUpdate(t *testing.T) { opts := arangodb.VertexUpdateOptions{ NewObject: &johnUpdated, - KeepNull: utils.NewT(true), + KeepNull: utils.NewType(true), } response, err := colVertex.UpdateVertex(ctx, johnResp.Key, johnUpdated, &opts) @@ -274,7 +274,7 @@ func Test_VerticesUpdate(t *testing.T) { opts := arangodb.VertexUpdateOptions{ NewObject: &johnUpdated, - KeepNull: utils.NewT(false), + KeepNull: utils.NewType(false), } response, err := colVertex.UpdateVertex(ctx, johnResp.Key, johnUpdated, &opts) diff --git a/v2/tests/helper_test.go b/v2/tests/helper_test.go index c5392bbd..2ba52011 100644 --- a/v2/tests/helper_test.go +++ b/v2/tests/helper_test.go @@ -167,5 +167,5 @@ func getBool(b *bool, d bool) bool { } func newVersion(val string) *arangodb.Version { - return utils.NewT(arangodb.Version(val)) + return utils.NewType(arangodb.Version(val)) } diff --git a/v2/tests/users_permissions_test.go b/v2/tests/users_permissions_test.go index 4adfc69d..44f79eff 100644 --- a/v2/tests/users_permissions_test.go +++ b/v2/tests/users_permissions_test.go @@ -118,6 +118,6 @@ func Test_UserPermission(t *testing.T) { }) }) }, WrapOptions{ - Parallel: utils.NewT(false), + Parallel: utils.NewType(false), }) } diff --git a/v2/tests/users_test.go b/v2/tests/users_test.go index a5e8bf7c..237bb5bf 100644 --- a/v2/tests/users_test.go +++ b/v2/tests/users_test.go @@ -98,7 +98,7 @@ func Test_Users(t *testing.T) { t.Run("Test update user", func(t *testing.T) { opts := &arangodb.UserOptions{ - Active: utils.NewT(false), + Active: utils.NewType(false), } u, err := client.UpdateUser(ctx, user1Name, opts) @@ -134,7 +134,7 @@ func Test_Users(t *testing.T) { }) }) }, WrapOptions{ - Parallel: utils.NewT(false), + Parallel: utils.NewType(false), }) } @@ -143,8 +143,8 @@ func Test_UserCreation(t *testing.T) { testCases := map[string]*arangodb.UserOptions{ "jan1": nil, - "george": {Password: "foo", Active: utils.NewT(false)}, - "candy": {Password: "ARANGODB_DEFAULT_ROOT_PASSWORD", Active: utils.NewT(true)}, + "george": {Password: "foo", Active: utils.NewType(false)}, + "candy": {Password: "ARANGODB_DEFAULT_ROOT_PASSWORD", Active: utils.NewType(true)}, "joe": {Extra: map[string]interface{}{"key": "value", "x": 5}}, "admin@api": nil, "測試用例": nil, @@ -181,6 +181,6 @@ func Test_UserCreation(t *testing.T) { }) } }, WrapOptions{ - Parallel: utils.NewT(false), + Parallel: utils.NewType(false), }) } diff --git a/v2/utils/type.go b/v2/utils/type.go index 17de728c..d6c37ca5 100644 --- a/v2/utils/type.go +++ b/v2/utils/type.go @@ -43,6 +43,6 @@ func IsList(i interface{}) bool { } } -func NewT[T any](val T) *T { +func NewType[T any](val T) *T { return &val } From 5dc97f56978bf0e8f8948bb3fb9dc69be57df7ae Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Fri, 4 Oct 2024 09:31:39 +0200 Subject: [PATCH 5/5] Update --- CHANGELOG.md | 2 +- v2/CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e11c2af7..4d75db06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Change Log ## [master](https://github.com/arangodb/go-driver/tree/master) (N/A) -- Expose `NewT` method +- Expose `NewType` method ## [1.6.4(https://github.com/arangodb/go-driver/tree/v1.6.4) (2024-09-27) - Switch to Go 1.22.5 diff --git a/v2/CHANGELOG.md b/v2/CHANGELOG.md index 47ad4cf5..63495812 100644 --- a/v2/CHANGELOG.md +++ b/v2/CHANGELOG.md @@ -1,7 +1,7 @@ # Change Log ## [master](https://github.com/arangodb/go-driver/tree/master) (N/A) -- Expose `NewT` method +- Expose `NewType` method ## [2.1.1](https://github.com/arangodb/go-driver/tree/v2.1.1) (2024-09-27) - Improve backup tests stability