-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_database_test.go
63 lines (56 loc) · 1.45 KB
/
create_database_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
package influxqb
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
var testCreateDatabase = []struct {
d string
b BuilderIf
s string
e bool
}{
{"Create Simple database no policy",
NewCreateDatabaseBuilder().WithName("DatabaseName"),
"CREATE DATABASE DatabaseName",
false,
},
{"Create Simple database With policy",
NewCreateDatabaseBuilder().WithName("DatabaseName").WithRetentionPolicy(
NewCreateRetentionPolicyBuilder().
WithReplicationFactor(3).
WithDurationString("1h").
WithShardDurationString("2h"),
),
"CREATE DATABASE DatabaseName WITH DURATION 1h0m0s REPLICATION 3 SHARD DURATION 2h0m0s",
false,
},
{
"Create database with future and past policy",
NewCreateDatabaseBuilder().
WithName("testdb").
WithRetentionPolicy(
NewCreateRetentionPolicyBuilder().
WithPolicyName("test_name").
WithDurationString("24h").
WithShardDurationString("10m").
WithReplicationFactor(2).
WithPastLimitString("67ms").
WithFutureLimitString("1h")),
"CREATE DATABASE testdb WITH DURATION 24h0m0s REPLICATION 2 SHARD DURATION 10m0s FUTURE LIMIT 1h PAST LIMIT 67ms NAME test_name",
false,
},
}
func TestCreateDatabaseBuilder(t *testing.T) {
for i, sample := range testCreateDatabase {
s, err := sample.b.Build()
fmt.Print("Test ", i, ": ", sample.d)
if sample.e {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}
assert.Equal(t, sample.s, s)
fmt.Println(" [OK]")
}
}