Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions test/agency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ import (
"context"
"crypto/tls"
"fmt"
"net/http"
"os"
"reflect"
"strings"
"testing"
"time"

driver "github.com/arangodb/go-driver"
"github.com/arangodb/go-driver/agency"
httpdriver "github.com/arangodb/go-driver/http"
"github.com/arangodb/go-driver/jwt"
"github.com/arangodb/go-driver/util"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"net/http"
"os"
"reflect"
"strings"
"testing"
"time"
)

// getAgencyEndpoints queries the cluster to get all agency endpoints.
Expand Down
38 changes: 38 additions & 0 deletions test/clean.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// DISCLAIMER
//
// Copyright 2018 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
//
// Author Ewout Prangsma
//

package test

import (
"context"
"testing"

"github.com/stretchr/testify/require"
)

type remove interface {
Remove(ctx context.Context) error
}

func clean(t *testing.T, ctx context.Context, col remove) {
require.NoError(t, col.Remove(ctx))
}
1 change: 1 addition & 0 deletions test/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ func TestResponseHeader(t *testing.T) {
var resp driver.Response
db := ensureDatabase(ctx, c, "_system", nil, t)
col := ensureCollection(ctx, db, "response_header_test", nil, t)
defer clean(t, ctx, col)

// `ETag` header must contain the `_rev` of the new document in quotes.
doc := map[string]string{
Expand Down
16 changes: 12 additions & 4 deletions test/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ func TestClusterDatabaseInventorySatellite(t *testing.T) {
if err != nil {
t.Fatalf("Failed to open _system database: %s", describe(err))
}
ensureCollection(ctx, db, name, &driver.CreateCollectionOptions{
col := ensureCollection(ctx, db, name, &driver.CreateCollectionOptions{
ReplicationFactor: driver.ReplicationFactorSatellite,
}, t)
defer clean(t, ctx, col)
h, err := cl.Health(ctx)
if err != nil {
t.Fatalf("Health failed: %s", describe(err))
Expand Down Expand Up @@ -185,11 +186,12 @@ func TestClusterDatabaseInventorySmartJoin(t *testing.T) {
if err != nil {
t.Fatalf("Failed to open _system database: %s", describe(err))
}
ensureCollection(ctx, db, name, &driver.CreateCollectionOptions{
col := ensureCollection(ctx, db, name, &driver.CreateCollectionOptions{
ShardKeys: []string{"_key:"},
SmartJoinAttribute: "smart",
NumberOfShards: 2,
}, t)
defer clean(t, ctx, col)
inv, err := cl.DatabaseInventory(ctx, db)
if err != nil {
t.Fatalf("DatabaseInventory failed: %s", describe(err))
Expand Down Expand Up @@ -225,9 +227,10 @@ func TestClusterDatabaseInventoryShardingStrategy(t *testing.T) {
if err != nil {
t.Fatalf("Failed to open _system database: %s", describe(err))
}
ensureCollection(ctx, db, name, &driver.CreateCollectionOptions{
col := ensureCollection(ctx, db, name, &driver.CreateCollectionOptions{
ShardingStrategy: driver.ShardingStrategyCommunityCompat,
}, t)
defer clean(t, ctx, col)
inv, err := cl.DatabaseInventory(ctx, db)
if err != nil {
t.Fatalf("DatabaseInventory failed: %s", describe(err))
Expand Down Expand Up @@ -261,6 +264,7 @@ func TestClusterMoveShard(t *testing.T) {
col, err := db.CreateCollection(ctx, "test_move_shard", &driver.CreateCollectionOptions{
NumberOfShards: 12,
})
defer clean(t, ctx, col)
if err != nil {
t.Fatalf("CreateCollection failed: %s", describe(err))
}
Expand Down Expand Up @@ -361,6 +365,7 @@ func TestClusterResignLeadership(t *testing.T) {
NumberOfShards: 12,
ReplicationFactor: 2,
})
defer clean(t, ctx, col)
if err != nil {
t.Fatalf("CreateCollection failed: %s", describe(err))
}
Expand Down Expand Up @@ -448,6 +453,7 @@ func TestClusterMoveShardWithViews(t *testing.T) {
col, err := db.CreateCollection(ctx, "test_move_shard_with_view", &driver.CreateCollectionOptions{
NumberOfShards: 12,
})
clean(t, ctx, col)
if err != nil {
t.Fatalf("CreateCollection failed: %s", describe(err))
}
Expand All @@ -457,7 +463,9 @@ func TestClusterMoveShardWithViews(t *testing.T) {
},
}
viewName := "test_move_shard_view"
if _, err := db.CreateArangoSearchView(ctx, viewName, opts); err != nil {
view, err := db.CreateArangoSearchView(ctx, viewName, opts)
clean(t, ctx, view)
if err != nil {
t.Fatalf("Failed to create view '%s': %s", viewName, describe(err))
}
h, err := cl.Health(ctx)
Expand Down
3 changes: 2 additions & 1 deletion test/database_collection_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
package test

import (
"github.com/dchest/uniuri"
"strings"
"testing"

"github.com/dchest/uniuri"

"github.com/arangodb/go-driver"
"github.com/stretchr/testify/require"
)
Expand Down
7 changes: 4 additions & 3 deletions test/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ package test
import (
"context"
"fmt"
"github.com/dchest/uniuri"
"github.com/stretchr/testify/require"
"strings"
"testing"

"github.com/dchest/uniuri"
"github.com/stretchr/testify/require"

"github.com/arangodb/go-driver"
)

// databaseName is helper to create database name in non-colliding way
func databaseName(parts ... string) string {
func databaseName(parts ...string) string {
return fmt.Sprintf("%s_%s", strings.Join(parts, "_"), uniuri.NewLen(8))
}

Expand Down
5 changes: 3 additions & 2 deletions test/foxx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ package test

import (
"context"
"github.com/arangodb/go-driver"
"github.com/stretchr/testify/require"
"os"
"testing"
"time"

"github.com/arangodb/go-driver"
"github.com/stretchr/testify/require"
)

func TestFoxxItzpapalotlService(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions test/graph_creation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ package test

import (
"context"
"github.com/arangodb/go-driver"
"github.com/stretchr/testify/require"
"testing"
"time"

"github.com/arangodb/go-driver"
"github.com/stretchr/testify/require"
)

func newGraphOpts(db driver.Database) (driver.CreateGraphOptions, []string) {
Expand Down Expand Up @@ -137,7 +138,6 @@ func Test_Graph_AdvancedCreate(t *testing.T) {
})
}


// Test_Graph_AdvancedCreate_Defaults will check if graph created have properly set replication factor
// and write concern by default
func Test_Graph_AdvancedCreate_Defaults(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions test/revisions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/arangodb/go-driver"
"github.com/stretchr/testify/require"
"net/http"
"testing"
"time"

"github.com/arangodb/go-driver"
"github.com/stretchr/testify/require"
)

func TestRevisionTree(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions test/server_mode_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func TestServerModeAndGrants(t *testing.T) {
db := ensureDatabase(ctx, c, "_system", nil, t)
colName := "server_mode_and_grants_test1"
col := ensureCollection(ctx, db, colName, nil, t)
clean(t, ctx, col)

// Get database & collection access
defaultDBAccess, err := u.GetDatabaseAccess(ctx, db)
Expand Down