-
Notifications
You must be signed in to change notification settings - Fork 428
/
Copy pathdatabase_role_gen_test.go
101 lines (83 loc) · 2.89 KB
/
database_role_gen_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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package example
import "testing"
func TestDatabaseRoles_Create(t *testing.T) {
id := RandomDatabaseObjectIdentifier(t)
// Minimal valid CreateDatabaseRoleOptions
defaultOpts := func() *CreateDatabaseRoleOptions {
return &CreateDatabaseRoleOptions{
name: id,
}
}
t.Run("validation: nil options", func(t *testing.T) {
var opts *CreateDatabaseRoleOptions = nil
assertOptsInvalidJoinedErrors(t, opts, ErrNilOptions)
})
t.Run("validation: valid identifier for [opts.name]", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsInvalidJoinedErrors(t, opts, ErrInvalidObjectIdentifier)
})
t.Run("validation: conflicting fields for [opts.OrReplace opts.IfNotExists]", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsInvalidJoinedErrors(t, opts, errOneOf("CreateDatabaseRoleOptions", "OrReplace", "IfNotExists"))
})
t.Run("basic", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsValidAndSQLEquals(t, opts, "TODO: fill me")
})
t.Run("all options", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsValidAndSQLEquals(t, opts, "TODO: fill me")
})
}
func TestDatabaseRoles_Alter(t *testing.T) {
id := RandomDatabaseObjectIdentifier(t)
// Minimal valid AlterDatabaseRoleOptions
defaultOpts := func() *AlterDatabaseRoleOptions {
return &AlterDatabaseRoleOptions{
name: id,
}
}
t.Run("validation: nil options", func(t *testing.T) {
var opts *AlterDatabaseRoleOptions = nil
assertOptsInvalidJoinedErrors(t, opts, ErrNilOptions)
})
t.Run("validation: valid identifier for [opts.name]", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsInvalidJoinedErrors(t, opts, ErrInvalidObjectIdentifier)
})
t.Run("validation: exactly one field from [opts.Rename opts.Set opts.Unset] should be present", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsInvalidJoinedErrors(t, opts, errExactlyOneOf("Rename", "Set", "Unset"))
})
t.Run("validation: valid identifier for [opts.Rename.Name]", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsInvalidJoinedErrors(t, opts, ErrInvalidObjectIdentifier)
})
t.Run("validation: at least one of the fields [opts.Set.NestedThirdLevel.Field] should be set", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsInvalidJoinedErrors(t, opts, errAtLeastOneOf("Field"))
})
t.Run("validation: at least one of the fields [opts.Unset.Comment] should be set", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsInvalidJoinedErrors(t, opts, errAtLeastOneOf("Comment"))
})
t.Run("basic", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsValidAndSQLEquals(t, opts, "TODO: fill me")
})
t.Run("all options", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsValidAndSQLEquals(t, opts, "TODO: fill me")
})
}