-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoption_test.go
57 lines (45 loc) · 1.11 KB
/
option_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
package biteship
import (
"errors"
"github.com/stretchr/testify/assert"
"io"
"testing"
)
func TestWithSecret_Apply(t *testing.T) {
someSecret := "alien exists"
client := Client{
SecretKey: "",
BiteshipUrl: "",
HttpRequest: nil,
}
WithSecret(someSecret).Apply(&client)
assert.Equal(t, client.SecretKey, someSecret)
assert.Empty(t, client.BiteshipUrl)
assert.Nil(t, client.HttpRequest)
}
func TestWithUrl_Apply(t *testing.T) {
someUrl := "https://google.com"
client := Client{
SecretKey: "",
BiteshipUrl: "",
HttpRequest: nil,
}
WithUrl(someUrl).Apply(&client)
assert.Empty(t, client.SecretKey)
assert.Equal(t, client.BiteshipUrl, someUrl)
assert.Nil(t, client.HttpRequest)
}
type httpMock struct{}
func (m httpMock) Call(method string, url string, secretKey string, body io.Reader, result interface{}) *Error {
return ErrorGo(errors.New("someerror"))
}
func TestWithHttpRequest_Apply(t *testing.T) {
mockHttp := httpMock{}
client := Client{
SecretKey: "",
BiteshipUrl: "",
HttpRequest: nil,
}
WithHttpRequest(mockHttp).Apply(&client)
assert.NotNil(t, client.HttpRequest)
}