-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvariadic_test.go
More file actions
76 lines (61 loc) · 1.86 KB
/
Copy pathvariadic_test.go
File metadata and controls
76 lines (61 loc) · 1.86 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
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
75
76
package mocker_test
import (
"errors"
"testing"
"github.com/stretchr/testify/suite"
"github.com/tencent/goom"
"github.com/tencent/goom/arg"
"github.com/tencent/goom/test"
)
func TestNewClients(t *testing.T) {
suite.Run(t, new(NewClientsTestSuite))
}
type NewClientsTestSuite struct {
suite.Suite
}
func (s *NewClientsTestSuite) SetupTest() {
mocker.OpenDebug()
}
func (s *NewClientsTestSuite) TestNewClients() {
s.Run("success", func() {
mock := mocker.Create()
mock.Func(test.NewClient).Return(nil, errors.New("failure"))
c, e := test.NewClient()
s.Equal((*test.Client)(nil), c)
s.Equal(errors.New("failure"), e)
})
}
func (s *NewClientsTestSuite) TestNewClientsWhen() {
s.Run("success", func() {
op := test.SetHttpClient()
mock := mocker.Create()
//mock.Func(elastic.NewClient).Return(((*elastic.Client)(nil), errors.New("failure")))
mock.Func(test.NewClient).Return(nil, errors.New("default")).
When(op, op).Return((*test.Client)(nil), errors.New("failure"))
c, e := test.NewClient(op, op)
s.Equal((*test.Client)(nil), c)
s.Equal(errors.New("failure"), e)
})
}
func (s *NewClientsTestSuite) TestNewClientsIn() {
s.Run("success", func() {
op := test.SetHttpClient()
mock := mocker.Create()
mock.Func(test.NewClient).Return(nil, errors.New("default")).
In([]test.ClientOptionFunc{op, op}, []test.ClientOptionFunc{op, op}).Return(nil, errors.New("failure"))
c, e := test.NewClient(op, op)
s.Equal((*test.Client)(nil), c)
s.Equal(errors.New("failure"), e)
})
}
func (s *NewClientsTestSuite) TestNewClientsWhenIn() {
s.Run("success", func() {
op := test.SetHttpClient()
mock := mocker.Create()
mock.Func(test.NewClient).Return(nil, errors.New("default")).
When(arg.In(op), arg.In(op)).Return(nil, errors.New("failure"))
c, e := test.NewClient(op, op)
s.Equal((*test.Client)(nil), c)
s.Equal(errors.New("failure"), e)
})
}