-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflags_test.go
33 lines (27 loc) · 1019 Bytes
/
flags_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
package golib
import (
"testing"
"github.com/stretchr/testify/suite"
)
type FlagsTestSuite struct {
AbstractTestSuite
}
func TestFlags(t *testing.T) {
suite.Run(t, new(FlagsTestSuite))
}
func (s *FlagsTestSuite) TestConvertLabels() {
s.Equal(map[string]string{"hello": "world", "super": "cool"}, ParseMap("hello=world,super=cool"))
s.Equal(map[string]string{"hello": "world", "invalid": ""}, ParseMap("hello=world,invalid"))
s.Empty(ParseMap(""))
s.Equal(map[string]string{"hello": "world", "super": "cool"}, ParseMap("hello = world , super= cool"))
}
func (s *FlagsTestSuite) TestConvertList() {
s.Equal([]string{"test", "super", "cool"}, ParseSlice("test,super,cool"))
s.Equal([]string{"hello"}, ParseSlice("hello,"))
s.Equal([]string{"hello"}, ParseSlice("hello"))
s.Equal([]string{"hello"}, ParseSlice(",hello"))
s.Equal([]string{"hello"}, ParseSlice(",,,hello"))
s.Empty(ParseSlice(""))
s.Empty(ParseSlice(" "))
s.Equal([]string{"test", "super", "cool"}, ParseSlice("test , super, cool"))
}