-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshow_test.go
123 lines (116 loc) · 3.28 KB
/
show_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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package myradio_test
import (
"reflect"
"testing"
myradio "github.com/UniversityRadioYork/myradio-go"
)
const getSearchMetaJson = `
[{
"show_id": 8675309,
"title": "Jenny I've Got Your Number",
"credits_string": "Tommy Tutone",
"credits": [
{
"type": 1,
"memberid": 666,
"user": {
"memberid": 666,
"fname": "Tommy",
"sname": "Tutone",
"public_email": "[email protected]",
"receive_email": false,
"photo": "/media/image_meta/MyRadioImageMetadata/1.jpeg",
"bio": "generic bio"
}
}
],
"description": "Tommy Tutone's got your number, and he's gotta make you his.",
"show_type_id": 1,
"seasons": {
"display": "season display",
"value": "https://myradio.example.com/seasons/512",
"title": "Seasons",
"url": "https://myradio.example.com/seasons/512"
},
"editlink": {
"display": "edit display",
"value": "https://myradio.example.com/edit/8675309",
"title": "Edit",
"url": "https://myradio.example.com/edit/8675309"
},
"applylink": {
"display": "apply display",
"value": "https://myradio.example.com/apply/8675309",
"title": "Apply",
"url": "https://myradio.example.com/apply/8675309"
},
"micrositelink": {
"display": "microsite display",
"value": "https://myradio.example.com/microsites/8675309",
"title": "Microsites",
"url": "https://myradio.example.com/microsites/8675309"
},
"photo": "https://myradio.example.com/photos/shows/8675309"
}]`
// TestGetSearchMetaUnmarshal tests the unmarshalling logic of GetSearchMeta.
// It does not test the API endpoint.
func TestGetSearchMetaUnmarshal(t *testing.T) {
expected := []myradio.ShowMeta{{
ShowID: 8675309,
Title: "Jenny I've Got Your Number",
CreditsString: "Tommy Tutone",
Credits: []myradio.Credit{
{
Type: 1,
MemberID: 666,
User: myradio.User{
MemberID: 666,
Fname: "Tommy",
Sname: "Tutone",
Email: "[email protected]",
Receiveemail: false,
Photo: "/media/image_meta/MyRadioImageMetadata/1.jpeg",
Bio: "generic bio",
},
},
},
Description: "Tommy Tutone's got your number, and he's gotta make you his.",
ShowTypeID: 1,
Season: myradio.Link{
Display: "season display",
Value: "https://myradio.example.com/seasons/512",
Title: "Seasons",
URL: "https://myradio.example.com/seasons/512",
},
EditLink: myradio.Link{
Display: "edit display",
Value: "https://myradio.example.com/edit/8675309",
Title: "Edit",
URL: "https://myradio.example.com/edit/8675309",
},
ApplyLink: myradio.Link{
Display: "apply display",
Value: "https://myradio.example.com/apply/8675309",
Title: "Apply",
URL: "https://myradio.example.com/apply/8675309",
},
MicroSiteLink: myradio.Link{
Display: "microsite display",
Value: "https://myradio.example.com/microsites/8675309",
Title: "Microsites",
URL: "https://myradio.example.com/microsites/8675309",
},
Photo: "https://myradio.example.com/photos/shows/8675309",
}}
session, err := myradio.MockSession([]byte(getSearchMetaJson))
if err != nil {
t.Error(err)
}
showMeta, err := session.GetSearchMeta("tutone")
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(showMeta, expected) {
t.Errorf("expected:\n%v\n\ngot:\n%v", expected, showMeta)
}
}