-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag_options_test.go
68 lines (50 loc) · 1.45 KB
/
tag_options_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
package env
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type TagOptionsTestSuite struct {
suite.Suite
}
func (s *TagOptionsTestSuite) TestParseTagEmpty() {
tag := ""
name, opts := parseTag(tag)
assert.Empty(s.T(), name)
assert.Empty(s.T(), opts)
}
func (s *TagOptionsTestSuite) TestParseTagOptsEmpty() {
tag := "SAMPLE_ENV_VAR"
name, opts := parseTag(tag)
assert.Empty(s.T(), opts)
assert.Equal(s.T(), tag, name)
}
func (s *TagOptionsTestSuite) TestParseTagOptsNonEmpty() {
tag := "SAMPLE_ENV_VAR,omitempty,file"
name, opts := parseTag(tag)
assert.Equal(s.T(), tagOptions("omitempty,file"), opts)
assert.Equal(s.T(), "SAMPLE_ENV_VAR", name)
}
func (s *TagOptionsTestSuite) TestTagContainsFirst() {
tag := "SAMPLE_ENV_VAR,omitempty,file"
_, opts := parseTag(tag)
assert.True(s.T(), opts.Contains("omitempty"))
}
func (s *TagOptionsTestSuite) TestTagContainsSecond() {
tag := "SAMPLE_ENV_VAR,omitempty,file"
_, opts := parseTag(tag)
assert.True(s.T(), opts.Contains("file"))
}
func (s *TagOptionsTestSuite) TestTagNotContains() {
tag := "SAMPLE_ENV_VAR,omitempty,file"
_, opts := parseTag(tag)
assert.False(s.T(), opts.Contains("notcontains"))
}
func (s *TagOptionsTestSuite) TestTagNotContainsEmpty() {
tag := "SAMPLE_ENV_VAR"
_, opts := parseTag(tag)
assert.False(s.T(), opts.Contains("notcontains"))
}
func TestTagOptionsTestSuite(t *testing.T) {
suite.Run(t, new(TagOptionsTestSuite))
}