forked from Virtomize/mailtrain-go-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinternal_test.go
40 lines (34 loc) · 907 Bytes
/
internal_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
package gomailtrain
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
type apiTestValue struct {
Input []string
Error error
}
func TestNewAPI(t *testing.T) {
testValues := []apiTestValue{
{[]string{"", "token"}, fmt.Errorf("url or token not set")},
{[]string{"test", ""}, fmt.Errorf("url or token not set")},
{[]string{"https://test.test", "token"}, nil},
{[]string{"test", "token"}, fmt.Errorf("parse \"test\": invalid URI for request")},
}
for _, test := range testValues {
api, err := NewAPI(test.Input[0], test.Input[1])
if err != nil {
assert.Equal(t, test.Error.Error(), err.Error())
} else {
assert.Equal(t, test.Input[0], api.endPoint.String())
assert.Equal(t, test.Input[1], api.token)
}
}
}
func TestSetDebug(t *testing.T) {
assert.False(t, DebugFlag)
SetDebug(true)
assert.True(t, DebugFlag)
SetDebug(false)
assert.False(t, DebugFlag)
}