-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvault_test.go
More file actions
49 lines (46 loc) · 1.3 KB
/
vault_test.go
File metadata and controls
49 lines (46 loc) · 1.3 KB
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
package cocoa
import (
"testing"
"github.com/evergreen-ci/utility"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNamedSecret(t *testing.T) {
t.Run("NewNamedSecret", func(t *testing.T) {
s := NewNamedSecret()
require.NotZero(t, s)
assert.Zero(t, *s)
})
t.Run("SetName", func(t *testing.T) {
name := "name"
s := NewNamedSecret().SetName(name)
assert.Equal(t, name, utility.FromStringPtr(s.Name))
})
t.Run("SetValue", func(t *testing.T) {
val := "value"
s := NewNamedSecret().SetValue(val)
assert.Equal(t, val, utility.FromStringPtr(s.Value))
})
t.Run("Validate", func(t *testing.T) {
t.Run("EmptyIsInvalid", func(t *testing.T) {
s := NewNamedSecret()
assert.Error(t, s.Validate())
})
t.Run("NameAndValueIsValid", func(t *testing.T) {
s := NewNamedSecret().SetName("name").SetValue("value")
assert.NoError(t, s.Validate())
})
t.Run("MissingNameIsInvalid", func(t *testing.T) {
s := NewNamedSecret().SetValue("value")
assert.Error(t, s.Validate())
})
t.Run("EmptyNameIsInvalid", func(t *testing.T) {
s := NewNamedSecret().SetName("").SetValue("value")
assert.Error(t, s.Validate())
})
t.Run("MissingValueIsInvalid", func(t *testing.T) {
s := NewNamedSecret().SetName("name")
assert.Error(t, s.Validate())
})
})
}