-
Notifications
You must be signed in to change notification settings - Fork 1
/
tunein_test.go
55 lines (40 loc) · 1.24 KB
/
tunein_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
package main
import (
"net/url"
"os"
"testing"
)
func TestConstructTuneinURL(t *testing.T) {
testURLHost := "http://google.com"
testArtist := "test"
testTitle := "title"
testPartnerID := "foo"
testPartnerKey := "bar"
testStationID := "baz"
os.Setenv("TUNEIN_PARTNER_ID", testPartnerID)
os.Setenv("TUNEIN_PARTNER_KEY", testPartnerKey)
os.Setenv("TUNEIN_STATION_ID", testStationID)
var testURL *url.URL
testURL, _ = url.Parse(testURLHost)
testParams := url.Values{}
testParams.Add("partnerId", testPartnerID)
testParams.Add("partnerKey", testPartnerKey)
testParams.Add("id", testStationID)
testParams.Add("artist", testArtist)
testParams.Add("title", testTitle)
testURL.RawQuery = testParams.Encode()
getURL := constructTuneinURL(testURLHost, testArtist, testTitle)
// fmt.Println(getURL.String())
if getURL != testURL.String() {
t.Errorf("URL Construct test: got %s, expected %s", getURL, testURL.String())
}
os.Unsetenv("TUNEIN_PARTNER_ID")
os.Unsetenv("TUNEIN_PARTNER_KEY")
os.Unsetenv("TUNEIN_STATION_ID")
}
func TestConstructTuneinURLNoEnvVars(t *testing.T) {
getData := constructTuneinURL("url.com", "test", "test")
if getData != "" {
t.Errorf("RUL Construct no ENV Key: expected empty string, got %s", getData)
}
}