-
Notifications
You must be signed in to change notification settings - Fork 139
/
Copy pathrosmar_test.go
74 lines (67 loc) · 1.93 KB
/
rosmar_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2023-Present Couchbase, Inc.
//
// Use of this software is governed by the Business Source License included
// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
// in that file, in accordance with the Business Source License, use of this
// software will be governed by the Apache License, Version 2.0, included in
// the file licenses/APL2.txt.
package rest
import (
"fmt"
"os"
"runtime"
"strings"
"testing"
"github.com/couchbase/sync_gateway/auth"
"github.com/couchbase/sync_gateway/base"
"github.com/couchbaselabs/rosmar"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestWalrusServerValues(t *testing.T) {
tempDir, err := os.MkdirTemp("", t.Name())
require.NoError(t, err)
serverConfig := &StartupConfig{API: APIConfig{CORS: &auth.CORSConfig{}, AdminInterface: DefaultAdminInterface}}
ctx := base.TestCtx(t)
serverContext := NewServerContext(ctx, serverConfig, false)
defer func() {
serverContext.Close(ctx)
assert.NoError(t, os.RemoveAll(tempDir))
}()
onDiskRosmarPath := tempDir
if runtime.GOOS == "windows" {
// windows uris look like rosmar:///c:/foo/bar
onDiskRosmarPath = "/" + strings.ReplaceAll(tempDir, "\\", "/")
}
testCases := []struct {
name string
server string
}{
{
name: "walrusInMemory",
server: "walrus:foo",
},
{
name: "rosmarInMemory",
server: rosmar.InMemoryURL,
},
{
name: "rosmarOnDisk",
server: "rosmar://" + onDiskRosmarPath,
},
}
for i, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
dbConfig := DbConfig{
Name: fmt.Sprintf("db%d", i),
BucketConfig: BucketConfig{Server: &testCase.server},
}
dbContext, err := serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, getOrAddDatabaseConfigOptions{
failFast: false,
useExisting: false,
})
require.NoError(t, err)
require.NotNil(t, dbContext)
})
}
}