-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathargs_test.go
52 lines (38 loc) · 1017 Bytes
/
args_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
package main
import (
"math/rand"
"os"
"strconv"
"testing"
"github.com/stretchr/testify/suite"
)
type ArgsTestSuite struct {
suite.Suite
serviceName string
}
func TestArgsUnitTestSuite(t *testing.T) {
s := new(ArgsTestSuite)
suite.Run(t, s)
}
// GetArgs
func (s *ArgsTestSuite) Test_GetArgs_ReturnsDefaultValues() {
args := getArgs()
s.Equal(1, args.Retry)
s.Equal(0, args.RetryInterval)
}
func (s *ArgsTestSuite) Test_GetArgs_ReturnsRetryFromEnv() {
expected := rand.Int()
intervalOrig := os.Getenv("DF_RETRY")
defer func() { os.Setenv("DF_RETRY", intervalOrig) }()
os.Setenv("DF_RETRY", strconv.Itoa(expected))
args := getArgs()
s.Equal(expected, args.Retry)
}
func (s *ArgsTestSuite) Test_GetArgs_ReturnsRetryIntervalFromEnv() {
expected := rand.Int()
intervalOrig := os.Getenv("DF_RETRY_INTERVAL")
defer func() { os.Setenv("DF_RETRY_INTERVAL", intervalOrig) }()
os.Setenv("DF_RETRY_INTERVAL", strconv.Itoa(expected))
args := getArgs()
s.Equal(expected, args.RetryInterval)
}