|
| 1 | +// |
| 2 | +// DISCLAIMER |
| 3 | +// |
| 4 | +// Copyright 2018 ArangoDB GmbH, Cologne, Germany |
| 5 | +// |
| 6 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +// you may not use this file except in compliance with the License. |
| 8 | +// You may obtain a copy of the License at |
| 9 | +// |
| 10 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +// |
| 12 | +// Unless required by applicable law or agreed to in writing, software |
| 13 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +// See the License for the specific language governing permissions and |
| 16 | +// limitations under the License. |
| 17 | +// |
| 18 | +// Copyright holder is ArangoDB GmbH, Cologne, Germany |
| 19 | +// |
| 20 | +// Author Ewout Prangsma |
| 21 | +// |
| 22 | + |
| 23 | +package test |
| 24 | + |
| 25 | +import ( |
| 26 | + "context" |
| 27 | + "testing" |
| 28 | +) |
| 29 | + |
| 30 | +// TestReplicationDatabaseInventory tests the Replication.DatabaseInventory method. |
| 31 | +func TestReplicationDatabaseInventory(t *testing.T) { |
| 32 | + ctx := context.Background() |
| 33 | + c := createClientFromEnv(t, true) |
| 34 | + rep := c.Replication() |
| 35 | + db, err := c.Database(ctx, "_system") |
| 36 | + if err != nil { |
| 37 | + t.Fatalf("Failed to open _system database: %s", describe(err)) |
| 38 | + } |
| 39 | + inv, err := rep.DatabaseInventory(ctx, db) |
| 40 | + if err != nil { |
| 41 | + t.Fatalf("DatabaseInventory failed: %s", describe(err)) |
| 42 | + } |
| 43 | + if len(inv.Collections) == 0 { |
| 44 | + t.Error("Expected multiple collections, got 0") |
| 45 | + } |
| 46 | + foundSystemCol := false |
| 47 | + for _, col := range inv.Collections { |
| 48 | + if col.Parameters.Name == "" { |
| 49 | + t.Error("Expected non-empty name") |
| 50 | + } |
| 51 | + if col.Parameters.IsSystem { |
| 52 | + foundSystemCol = true |
| 53 | + } |
| 54 | + } |
| 55 | + if !foundSystemCol { |
| 56 | + t.Error("Expected multiple system collections, found none") |
| 57 | + } |
| 58 | +} |
0 commit comments