Skip to content

Commit 0c74253

Browse files
authored
Expose NewType method (#625)
1 parent 4cad4de commit 0c74253

33 files changed

+332
-270
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Change Log
22

33
## [master](https://github.com/arangodb/go-driver/tree/master) (N/A)
4+
- Expose `NewType` method
45

56
## [1.6.4(https://github.com/arangodb/go-driver/tree/v1.6.4) (2024-09-27)
67
- Switch to Go 1.22.5

test/arangosearch_analyzers_test.go

+30-29
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2018-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2018-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import (
2828
"github.com/stretchr/testify/require"
2929

3030
"github.com/arangodb/go-driver"
31+
"github.com/arangodb/go-driver/util"
3132
)
3233

3334
func newInt(v int) *int {
@@ -139,7 +140,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
139140
Properties: driver.ArangoSearchAnalyzerProperties{
140141
Min: newInt64(1),
141142
Max: newInt64(14),
142-
PreserveOriginal: newBool(false),
143+
PreserveOriginal: util.NewType(false),
143144
},
144145
},
145146
},
@@ -152,7 +153,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
152153
Properties: driver.ArangoSearchAnalyzerProperties{
153154
Min: newInt64(1),
154155
Max: newInt64(14),
155-
PreserveOriginal: newBool(false),
156+
PreserveOriginal: util.NewType(false),
156157
},
157158
},
158159
ExpectedDefinition: &driver.ArangoSearchAnalyzerDefinition{
@@ -161,7 +162,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
161162
Properties: driver.ArangoSearchAnalyzerProperties{
162163
Min: newInt64(1),
163164
Max: newInt64(14),
164-
PreserveOriginal: newBool(false),
165+
PreserveOriginal: util.NewType(false),
165166

166167
// Check defaults for 3.6
167168
StartMarker: newString(""),
@@ -179,7 +180,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
179180
Properties: driver.ArangoSearchAnalyzerProperties{
180181
Min: newInt64(1),
181182
Max: newInt64(14),
182-
PreserveOriginal: newBool(false),
183+
PreserveOriginal: util.NewType(false),
183184
StartMarker: newString("^"),
184185
EndMarker: newString("^"),
185186
StreamType: newArangoSearchNGramStreamType(driver.ArangoSearchNGramStreamUTF8),
@@ -199,7 +200,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
199200
Properties: driver.ArangoSearchAnalyzerProperties{
200201
Min: newInt64(1),
201202
Max: newInt64(14),
202-
PreserveOriginal: newBool(false),
203+
PreserveOriginal: util.NewType(false),
203204
StartMarker: newString("^"),
204205
EndMarker: newString("^"),
205206
StreamType: newArangoSearchNGramStreamType(driver.ArangoSearchNGramStreamUTF8),
@@ -217,11 +218,11 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
217218
Type: driver.ArangoSearchAnalyzerTypeAQL,
218219
Properties: driver.ArangoSearchAnalyzerProperties{
219220
QueryString: `FOR year IN [ 2011, 2012, 2013 ] FOR quarter IN [ 1, 2, 3, 4 ] RETURN { year, quarter, formatted: CONCAT(quarter, " / ", year)}`,
220-
CollapsePositions: newBool(true),
221-
KeepNull: newBool(false),
222-
BatchSize: newInt(10),
221+
CollapsePositions: util.NewType(true),
222+
KeepNull: util.NewType(false),
223+
BatchSize: util.NewType(10),
223224
ReturnType: driver.ArangoSearchAnalyzerAQLReturnTypeString.New(),
224-
MemoryLimit: newInt(1024 * 1024),
225+
MemoryLimit: util.NewType(1024 * 1024),
225226
},
226227
},
227228
},
@@ -233,9 +234,9 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
233234
Type: driver.ArangoSearchAnalyzerTypeGeoPoint,
234235
Properties: driver.ArangoSearchAnalyzerProperties{
235236
Options: &driver.ArangoSearchAnalyzerGeoOptions{
236-
MaxCells: newInt(20),
237-
MinLevel: newInt(4),
238-
MaxLevel: newInt(23),
237+
MaxCells: util.NewType(20),
238+
MinLevel: util.NewType(4),
239+
MaxLevel: util.NewType(23),
239240
},
240241
Latitude: []string{},
241242
Longitude: []string{},
@@ -250,9 +251,9 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
250251
Type: driver.ArangoSearchAnalyzerTypeGeoJSON,
251252
Properties: driver.ArangoSearchAnalyzerProperties{
252253
Options: &driver.ArangoSearchAnalyzerGeoOptions{
253-
MaxCells: newInt(20),
254-
MinLevel: newInt(4),
255-
MaxLevel: newInt(23),
254+
MaxCells: util.NewType(20),
255+
MinLevel: util.NewType(4),
256+
MaxLevel: util.NewType(23),
256257
},
257258
Type: driver.ArangoSearchAnalyzerGeoJSONTypeShape.New(),
258259
},
@@ -267,9 +268,9 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
267268
Properties: driver.ArangoSearchAnalyzerProperties{
268269
Format: driver.FormatLatLngInt.New(),
269270
Options: &driver.ArangoSearchAnalyzerGeoOptions{
270-
MaxCells: newInt(20),
271-
MinLevel: newInt(4),
272-
MaxLevel: newInt(23),
271+
MaxCells: util.NewType(20),
272+
MinLevel: util.NewType(4),
273+
MaxLevel: util.NewType(23),
273274
},
274275
Type: driver.ArangoSearchAnalyzerGeoJSONTypeShape.New(),
275276
},
@@ -280,9 +281,9 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
280281
Properties: driver.ArangoSearchAnalyzerProperties{
281282
Format: driver.FormatLatLngInt.New(),
282283
Options: &driver.ArangoSearchAnalyzerGeoOptions{
283-
MaxCells: newInt(20),
284-
MinLevel: newInt(4),
285-
MaxLevel: newInt(23),
284+
MaxCells: util.NewType(20),
285+
MinLevel: util.NewType(4),
286+
MaxLevel: util.NewType(23),
286287
},
287288
Type: driver.ArangoSearchAnalyzerGeoJSONTypeShape.New(),
288289
},
@@ -326,7 +327,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
326327
Name: "my-stopWords",
327328
Type: driver.ArangoSearchAnalyzerTypeStopwords,
328329
Properties: driver.ArangoSearchAnalyzerProperties{
329-
Hex: newBool(true),
330+
Hex: util.NewType(true),
330331
Stopwords: []string{
331332
"616e64",
332333
"746865",
@@ -337,7 +338,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
337338
Name: "my-stopWords",
338339
Type: driver.ArangoSearchAnalyzerTypeStopwords,
339340
Properties: driver.ArangoSearchAnalyzerProperties{
340-
Hex: newBool(true),
341+
Hex: util.NewType(true),
341342
Stopwords: []string{
342343
"616e64",
343344
"746865",
@@ -356,7 +357,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
356357
Analyzer: &driver.ArangoSearchAnalyzerDefinition{
357358
Type: driver.ArangoSearchAnalyzerTypeStopwords,
358359
Properties: driver.ArangoSearchAnalyzerProperties{
359-
Hex: newBool(true),
360+
Hex: util.NewType(true),
360361
Stopwords: []string{
361362
"616e64",
362363
"746865",
@@ -373,7 +374,7 @@ func TestArangoSearchAnalyzerEnsureAnalyzer(t *testing.T) {
373374
Analyzer: &driver.ArangoSearchAnalyzerDefinition{
374375
Type: driver.ArangoSearchAnalyzerTypeStopwords,
375376
Properties: driver.ArangoSearchAnalyzerProperties{
376-
Hex: newBool(true),
377+
Hex: util.NewType(true),
377378
Stopwords: []string{
378379
"616e64",
379380
"746865",
@@ -450,7 +451,7 @@ func TestArangoSearchAnalyzerGet(t *testing.T) {
450451
Properties: driver.ArangoSearchAnalyzerProperties{
451452
Min: newInt64(1),
452453
Max: newInt64(14),
453-
PreserveOriginal: newBool(false),
454+
PreserveOriginal: util.NewType(false),
454455
},
455456
}
456457
ensureAnalyzer(ctx, db, def, t)
@@ -484,7 +485,7 @@ func TestArangoSearchAnalyzerGetAll(t *testing.T) {
484485
Properties: driver.ArangoSearchAnalyzerProperties{
485486
Min: newInt64(1),
486487
Max: newInt64(14),
487-
PreserveOriginal: newBool(false),
488+
PreserveOriginal: util.NewType(false),
488489
},
489490
}
490491
ensureAnalyzer(ctx, db, def, t)
@@ -524,7 +525,7 @@ func TestArangoSearchAnalyzerRemove(t *testing.T) {
524525
Properties: driver.ArangoSearchAnalyzerProperties{
525526
Min: newInt64(1),
526527
Max: newInt64(14),
527-
PreserveOriginal: newBool(false),
528+
PreserveOriginal: util.NewType(false),
528529
},
529530
}
530531
a := ensureAnalyzer(ctx, db, def, t)

test/collection_test.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2017-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2017-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ import (
3131
"github.com/stretchr/testify/require"
3232

3333
driver "github.com/arangodb/go-driver"
34+
"github.com/arangodb/go-driver/util"
3435
)
3536

3637
// ensureCollection is a helper to check if a collection exists and create if if needed.
@@ -114,7 +115,7 @@ func TestCollection_CacheEnabled(t *testing.T) {
114115
t.Run("False", func(t *testing.T) {
115116
name := "test_create_collection_cache_false"
116117
_, err := db.CreateCollection(nil, name, &driver.CreateCollectionOptions{
117-
CacheEnabled: newBool(false),
118+
CacheEnabled: util.NewType(false),
118119
})
119120
require.NoError(t, err)
120121

@@ -131,7 +132,7 @@ func TestCollection_CacheEnabled(t *testing.T) {
131132
t.Run("True", func(t *testing.T) {
132133
name := "test_create_collection_cache_true"
133134
_, err := db.CreateCollection(nil, name, &driver.CreateCollectionOptions{
134-
CacheEnabled: newBool(true),
135+
CacheEnabled: util.NewType(true),
135136
})
136137
require.NoError(t, err)
137138

@@ -148,7 +149,7 @@ func TestCollection_CacheEnabled(t *testing.T) {
148149
t.Run("With update", func(t *testing.T) {
149150
name := "test_create_collection_cache_update"
150151
_, err := db.CreateCollection(nil, name, &driver.CreateCollectionOptions{
151-
CacheEnabled: newBool(false),
152+
CacheEnabled: util.NewType(false),
152153
})
153154
require.NoError(t, err)
154155

@@ -162,7 +163,7 @@ func TestCollection_CacheEnabled(t *testing.T) {
162163
require.False(t, prop.CacheEnabled)
163164

164165
err = col.SetProperties(nil, driver.SetCollectionPropertiesOptions{
165-
CacheEnabled: newBool(true),
166+
CacheEnabled: util.NewType(true),
166167
})
167168
require.NoError(t, err)
168169

test/index_ensure_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2017-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2017-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ import (
2929
"github.com/stretchr/testify/require"
3030

3131
driver "github.com/arangodb/go-driver"
32+
"github.com/arangodb/go-driver/util"
3233
)
3334

3435
// TestEnsureFullTextIndex creates a collection with a full text index.
@@ -537,8 +538,8 @@ func TestEnsureInvertedIndex(t *testing.T) {
537538
Name: "inverted-opt",
538539
PrimarySort: driver.InvertedIndexPrimarySort{
539540
Fields: []driver.ArangoSearchPrimarySortEntry{
540-
{Field: "test1", Ascending: newBool(true)},
541-
{Field: "test2", Ascending: newBool(false)},
541+
{Field: "test1", Ascending: util.NewType(true)},
542+
{Field: "test2", Ascending: util.NewType(false)},
542543
},
543544
Compression: driver.PrimarySortCompressionLz4,
544545
},
@@ -554,8 +555,8 @@ func TestEnsureInvertedIndex(t *testing.T) {
554555
Name: "inverted-opt-nested",
555556
PrimarySort: driver.InvertedIndexPrimarySort{
556557
Fields: []driver.ArangoSearchPrimarySortEntry{
557-
{Field: "test1", Ascending: newBool(true)},
558-
{Field: "test2", Ascending: newBool(false)},
558+
{Field: "test1", Ascending: util.NewType(true)},
559+
{Field: "test2", Ascending: util.NewType(false)},
559560
},
560561
Compression: driver.PrimarySortCompressionLz4,
561562
},
@@ -588,7 +589,7 @@ func TestEnsureInvertedIndex(t *testing.T) {
588589
Name: "inverted-opt-optimize-top-k",
589590
PrimarySort: driver.InvertedIndexPrimarySort{
590591
Fields: []driver.ArangoSearchPrimarySortEntry{
591-
{Field: "field1", Ascending: newBool(true)},
592+
{Field: "field1", Ascending: util.NewType(true)},
592593
},
593594
Compression: driver.PrimarySortCompressionLz4,
594595
},

test/view_alias_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2020-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import (
2727
"github.com/stretchr/testify/require"
2828

2929
"github.com/arangodb/go-driver"
30+
"github.com/arangodb/go-driver/util"
3031
)
3132

3233
// ensureArangoSearchView is a helper to check if an arangosearch view exists and create it if needed.
@@ -76,8 +77,8 @@ func TestSearchViewsAlias(t *testing.T) {
7677
Name: nameInvInd,
7778
PrimarySort: driver.InvertedIndexPrimarySort{
7879
Fields: []driver.ArangoSearchPrimarySortEntry{
79-
{Field: "test1", Ascending: newBool(true)},
80-
{Field: "test2", Ascending: newBool(false)},
80+
{Field: "test1", Ascending: util.NewType(true)},
81+
{Field: "test2", Ascending: util.NewType(false)},
8182
},
8283
Compression: driver.PrimarySortCompressionLz4,
8384
},

0 commit comments

Comments
 (0)