Skip to content

Commit 9926b07

Browse files
authored
Improve tests (#513)
1 parent 1380028 commit 9926b07

File tree

7 files changed

+17
-12
lines changed

7 files changed

+17
-12
lines changed

Dockerfile.debug

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM golang:1.19.4 as builder
1+
ARG GOVERSION
2+
FROM golang:${GOVERSION} as builder
23

34
ARG TESTS_DIRECTORY
45
ARG TESTS_ROOT_PATH="."

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,12 @@ __test_v2_go_test:
434434

435435
__test_debug__:
436436
ifeq ("$(DEBUG)", "true")
437-
@docker build -f Dockerfile.debug --build-arg "TESTS_DIRECTORY=./test" -t $(GOIMAGE) .
437+
@docker build -f Dockerfile.debug --build-arg GOVERSION=$(GOVERSION) --build-arg "TESTS_DIRECTORY=./test" -t $(GOIMAGE) .
438438
endif
439439

440440
__test_v2_debug__:
441441
ifeq ("$(DEBUG)", "true")
442-
@docker build -f Dockerfile.debug --build-arg "TESTS_DIRECTORY=./tests" --build-arg "TESTS_ROOT_PATH=v2" -t $(GOIMAGE) .
442+
@docker build -f Dockerfile.debug --build-arg GOVERSION=$(GOVERSION) --build-arg "TESTS_DIRECTORY=./tests" --build-arg "TESTS_ROOT_PATH=v2" -t $(GOIMAGE) .
443443
endif
444444

445445
__dir_setup:

client_server_info_impl.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ func (c *client) echo(ctx context.Context) error {
140140
if err != nil {
141141
return WithStack(err)
142142
}
143+
144+
// Velocypack requires non-empty body for versions < 3.11.
145+
req, err = req.SetBody("echo")
146+
if err != nil {
147+
return WithStack(err)
148+
}
149+
143150
applyContextSettings(ctx, req)
144151
resp, err := c.conn.Do(ctx, req)
145152
if err != nil {

test/database_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func TestDatabaseNameUnicode(t *testing.T) {
208208
func TestCreateDatabaseReplication2(t *testing.T) {
209209
ctx := context.Background()
210210
c := createClientFromEnv(t, true)
211-
EnsureVersion(t, ctx, c).CheckVersion(MinimumVersion("3.12.0"))
211+
EnsureVersion(t, ctx, c).CheckVersion(MinimumVersion("3.12.0")).Cluster()
212212

213213
name := "create_test_replication2"
214214
opts := driver.CreateDatabaseOptions{Options: driver.CreateDatabaseDefaultOptions{

v2/arangodb/client_server_info_impl.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ package arangodb
2222

2323
import (
2424
"context"
25-
"fmt"
2625
"net/http"
2726

2827
"github.com/arangodb/go-driver/v2/arangodb/shared"
@@ -128,7 +127,6 @@ func (c clientServerInfo) ServerRole(ctx context.Context) (ServerRole, error) {
128127
return role, nil
129128
}
130129

131-
fmt.Println(response.Mode)
132130
if response.Mode != "resilient" {
133131
// Single server mode.
134132
return role, nil
@@ -154,7 +152,8 @@ func (c clientServerInfo) echo(ctx context.Context) error {
154152
shared.ResponseStruct `json:",inline"`
155153
}
156154

157-
resp, err := connection.CallGet(ctx, c.client.connection, url, &response)
155+
// Velocypack requires non-empty body for versions < 3.11.
156+
resp, err := connection.CallGet(ctx, c.client.connection, url, &response, connection.WithBody("echo"))
158157
if err != nil {
159158
return errors.WithStack(err)
160159
}

v2/tests/client_server_info_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ import (
3030
"github.com/arangodb/go-driver/v2/arangodb"
3131
)
3232

33-
// Test_ServerRole tests server role for all instances.
33+
// Test_ServerRole tests a server role for all instances.
3434
func Test_ServerRole(t *testing.T) {
3535
Wrap(t, func(t *testing.T, client arangodb.Client) {
36-
withContext(time.Second*10, func(ctx context.Context) error {
36+
withContextT(t, 10*time.Second, func(ctx context.Context, _ testing.TB) {
3737
testMode := getTestMode()
3838

3939
t.Run("user endpoint", func(t *testing.T) {
@@ -48,8 +48,6 @@ func Test_ServerRole(t *testing.T) {
4848
require.Equal(t, role, arangodb.ServerRoleSingleActive)
4949
}
5050
})
51-
52-
return nil
5351
})
5452
})
5553
}

v2/tests/database_transactions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func Test_DatabaseTransactions_DocumentLock(t *testing.T) {
250250

251251
func Test_DatabaseTransactions_List(t *testing.T) {
252252
Wrap(t, func(t *testing.T, client arangodb.Client) {
253-
withContextT(t, 30*time.Second, func(ctx context.Context, _ testing.TB) {
253+
withContextT(t, 60*time.Second, func(ctx context.Context, _ testing.TB) {
254254
WithDatabase(t, client, nil, func(db arangodb.Database) {
255255
t.Run("List all transactions", func(t *testing.T) {
256256
t1, err := db.BeginTransaction(ctx, arangodb.TransactionCollections{}, nil)

0 commit comments

Comments
 (0)