-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Brooke-fix-end-of-time
- Loading branch information
Showing
3 changed files
with
192 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
language: go | ||
sudo: false | ||
|
||
go: | ||
- 1.6 | ||
- 1.7 | ||
- 1.8 | ||
- tip | ||
|
||
notifications: | ||
email: false | ||
go: | ||
- 1.6.x | ||
- 1.7.x | ||
- 1.8.x | ||
- tip | ||
|
||
before_install: | ||
- go get github.com/mattn/goveralls | ||
- if [ "$TRAVIS_GO_VERSION" = "1.8" ]; then go get github.com/mattn/goveralls; fi | ||
script: | ||
- $HOME/gopath/bin/goveralls -service=travis-ci | ||
- if [ "$TRAVIS_GO_VERSION" = "1.8" ]; then $HOME/gopath/bin/goveralls -service=travis-ci; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
package myradio_test | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"time" | ||
|
||
myradio "github.com/UniversityRadioYork/myradio-go" | ||
) | ||
|
||
const positionJSON = ` | ||
[{ | ||
"User": { | ||
"memberid": 10, | ||
"fname": "John", | ||
"sname": "Smith", | ||
"sex": "m", | ||
"public_email": "john.smith@example.org.uk", | ||
"url": "//example.org.uk/myradio/Profile/view/?memberid=10", | ||
"receive_email": true, | ||
"photo": "/media/image_meta/MyRadioImageMetadata/1.jpeg", | ||
"bio": "generic bio" | ||
}, | ||
"from": 1479081600, | ||
"memberofficerid": 1, | ||
"position": { | ||
"officerid": 2, | ||
"name": "Station Manager", | ||
"alias": "station.manager", | ||
"team": { | ||
"teamid": 1, | ||
"name": "Station Management", | ||
"alias": "management", | ||
"ordering": 10, | ||
"description": "", | ||
"status": "c" | ||
}, | ||
"ordering": 2, | ||
"description": "", | ||
"status": "c", | ||
"type": "a" | ||
} | ||
}]` | ||
|
||
// TestGetTeamHeadPositions tests the getter for head positions of a team. | ||
// It does not test the API endpoint. | ||
func TestGetTeamHeadPositions(t *testing.T) { | ||
expected := []myradio.Officer{ | ||
{ | ||
User: myradio.User{ | ||
Memberid: 10, | ||
Fname: "John", | ||
Sname: "Smith", | ||
Sex: "m", | ||
Email: "john.smith@example.org.uk", | ||
Receiveemail: true, | ||
}, | ||
From: time.Unix(1479081600, 0), | ||
FromRaw: 1479081600, | ||
MemberOfficerID: 1, | ||
Position: myradio.OfficerPosition{ | ||
OfficerID: 2, | ||
Name: "Station Manager", | ||
Alias: "station.manager", | ||
Team: myradio.Team{ | ||
TeamID: 1, | ||
Name: "Station Management", | ||
Alias: "management", | ||
Ordering: 10, | ||
Description: "", | ||
Status: "c", | ||
}, | ||
Ordering: 2, | ||
Description: "", | ||
Status: "c", | ||
Type: "a", | ||
}, | ||
}, | ||
} | ||
|
||
session, err := myradio.MockSession([]byte(positionJSON)) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
heads, err := session.GetTeamHeadPositions(1, nil) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
if !reflect.DeepEqual(heads, expected) { | ||
t.Errorf("expected:\n%v\n\ngot:\n%v", expected, heads) | ||
} | ||
} | ||
|
||
// TestGetTeamAssistantHeadPositions tests the getter for assistant head positions of a team. | ||
// It does not test the API endpoint. | ||
func TestGetTeamAssistantHeadPositions(t *testing.T) { | ||
expected := []myradio.Officer{ | ||
{ | ||
User: myradio.User{ | ||
Memberid: 10, | ||
Fname: "John", | ||
Sname: "Smith", | ||
Sex: "m", | ||
Email: "john.smith@example.org.uk", | ||
Receiveemail: true, | ||
}, | ||
From: time.Unix(1479081600, 0), | ||
FromRaw: 1479081600, | ||
MemberOfficerID: 1, | ||
Position: myradio.OfficerPosition{ | ||
OfficerID: 2, | ||
Name: "Station Manager", | ||
Alias: "station.manager", | ||
Team: myradio.Team{ | ||
TeamID: 1, | ||
Name: "Station Management", | ||
Alias: "management", | ||
Ordering: 10, | ||
Description: "", | ||
Status: "c", | ||
}, | ||
Ordering: 2, | ||
Description: "", | ||
Status: "c", | ||
Type: "a", | ||
}, | ||
}, | ||
} | ||
|
||
session, err := myradio.MockSession([]byte(positionJSON)) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
heads, err := session.GetTeamAssistantHeadPositions(1, nil) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
if !reflect.DeepEqual(heads, expected) { | ||
t.Errorf("expected:\n%v\n\ngot:\n%v", expected, heads) | ||
} | ||
} |