-
Notifications
You must be signed in to change notification settings - Fork 2
/
media_test.go
85 lines (78 loc) · 1.68 KB
/
media_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
77
78
79
80
81
82
83
84
85
package goprowifi
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestClient_getMediaList(t *testing.T) {
type fields struct {
myDoer Doer
}
tests := []struct {
name string
fields fields
wantReply []*Media
wantHTTPStatus int
wantErr error
}{
{
name: "Hero5 OK",
fields: fields{
myDoer: testDoer{
responseCode: 200,
response: `{
"id": "3806895087272624399",
"media": [
{
"d": "100GOPRO",
"fs": [
{
"n": "GOPR1130.MP4",
"mod": "1539705058",
"ls": "11170499",
"s": "188100018"
},
{
"n": "GOPR1147.JPG",
"mod": "1539960090",
"s": "3843146"
}
]
}
]
}`,
},
},
wantReply: []*Media{
{
Device: "100GOPRO",
EpochTimestamp: "1539705058",
FileName: "GOPR1130.MP4",
MediaType: "MP4",
Ls: "11170499",
S: "188100018",
},
{
Device: "100GOPRO",
EpochTimestamp: "1539960090",
FileName: "GOPR1147.JPG",
MediaType: "JPG",
Ls: "",
S: "3843146",
},
},
wantHTTPStatus: 200,
wantErr: nil,
// wantErr: errors.New("got false response"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
hero := CreateTestRestClient(tt.fields.myDoer)
gotReply, gotHTTPStatus, err := hero.getMediaList()
if err == nil {
assert.Equal(t, tt.wantHTTPStatus, gotHTTPStatus, "HTTPStatus did not match")
assert.Equal(t, tt.wantReply, gotReply, "Reply did not match")
}
})
}
}