-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgofig_test.go
74 lines (57 loc) · 1.38 KB
/
gofig_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
package gofig
import (
"os"
"testing"
. "launchpad.net/gocheck"
)
// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { TestingT(t) }
type BaseSuite struct {
}
var _ = Suite(&BaseSuite{})
func (s *BaseSuite) SetUpSuite(c *C) {
os.Clearenv()
os.Setenv("FOO", "bar")
}
func (s *BaseSuite) TearDownSuite(c *C) {
os.Clearenv()
}
func (s *BaseSuite) TestString(c *C) {
value, err := String("FOO")
c.Assert(err, IsNil)
c.Check(value, Equals, "bar")
}
func (s *BaseSuite) TestMissingSting(c *C) {
_, err := String("NOPE")
c.Check(err, NotNil)
}
func (s *BaseSuite) TestDefaultString(c *C) {
value := StringDefault("FOO", "banana")
c.Check(value, Equals, "bar")
}
func (s *BaseSuite) TestMissingDefaultString(c *C) {
value := StringDefault("NOPE", "banana")
c.Check(value, Equals, "banana")
}
func (s *BaseSuite) TestStringVar(c *C) {
var value string
err := StringVar(&value, "FOO")
c.Assert(err, IsNil)
c.Check(value, Equals, "bar")
}
func (s *BaseSuite) TestMissingStringVar(c *C) {
var value string
err := StringVar(&value, "NOPE")
c.Check(err, NotNil)
}
func (s *BaseSuite) TestDefaultStringVar(c *C) {
var value string
StringVarDefault(&value, "FOO", "banana")
c.Check(value, Equals, "bar")
}
func (s *BaseSuite) TestMissingDefaultStringVar(c *C) {
var value string
StringVarDefault(&value, "NOPE", "banana")
}
func (s *BaseSuite) TestInt(c *C) {
}