-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourseLocations_test.go
76 lines (70 loc) · 1.8 KB
/
courseLocations_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
75
76
package axcelerate
import (
"bytes"
"io/ioutil"
"net/http"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCoursesService_GetCoursesLocations(t *testing.T) {
type fields struct {
StatusCode int
Body string
}
type args struct {
public bool
onlyFuture bool
}
tests := []struct {
name string
fields fields
args args
want []Location
want1 *Response
wantErr bool
}{
{
name: "Full Body",
fields: fields{
StatusCode: 200,
Body: `["108 Fairley St","Adelaide","Armidale"]`,
},
args: args{public: true,
onlyFuture: true},
want: []Location{"108 Fairley St", "Adelaide", "Armidale"},
want1: &Response{
StatusCode: 200,
Body: `["108 Fairley St","Adelaide","Armidale"]`,
ContentLength: 0,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tclient := NewTestClient(func(req *http.Request) *http.Response {
return &http.Response{
StatusCode: tt.fields.StatusCode,
Body: ioutil.NopCloser(bytes.NewBufferString(tt.fields.Body)),
Header: make(http.Header),
}
})
client, _ := NewClient("", "", HttpClient(tclient))
s := &CoursesService{
client: client,
}
got, got1, err := s.GetCoursesLocations(tt.args.public, tt.args.onlyFuture)
if err == nil {
assert.Equal(t, tt.fields.StatusCode, got1.StatusCode, "HTTPStatus did not match")
assert.Equal(t, tt.fields.Body, got1.Body, "Body did not match")
assert.Equal(t, tt.want, got, "Response")
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("CoursesService.GetCoursesLocations() got = %v, want %v", got, tt.want)
}
if !reflect.DeepEqual(got1, tt.want1) {
t.Errorf("CoursesService.GetCoursesLocations() got1 = %v, want %v", got1, tt.want1)
}
})
}
}