-
Notifications
You must be signed in to change notification settings - Fork 2
/
news_test.go
53 lines (44 loc) · 1.75 KB
/
news_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
package kettle
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestISteamNewsServiceGetNewsForApp(t *testing.T) {
t.Parallel()
const filePath = "./json/isteamnews/getnewsforapp.json"
httpClient, mux, server := testServer()
defer server.Close()
mux.HandleFunc("/ISteamNews/GetNewsForApp/v2/", func(w http.ResponseWriter, r *http.Request) {
assertMethod(t, "GET", r)
assertQuery(t, map[string]string{
"key": "",
"appid": "440",
"maxlength": "300",
"count": "3",
}, r)
b, err := getTestFile(filePath)
if err != nil {
t.Fatalf("Failed to open testfile %s", filePath)
}
w.Header().Set("Content-Type", "application/json")
w.Write(b)
})
client := NewClient(httpClient, "")
news, _, err := client.ISteamNewsService.GetNewsForApp(&GetNewsForAppParams{
AppID: 440,
Count: 3,
MaxLength: 300,
})
assert.Nil(t, err)
assert.Len(t, news, 3)
assert.Equal(t, "91593954435862753", news[0].GID)
assert.Equal(t, "UGC League Winter 2017 Season is Starting!", news[0].Title)
assert.Equal(t, "http://store.steampowered.com/news/externalpost/tf2_blog/91593954435862753", news[0].URL)
assert.Equal(t, true, news[0].ExternalURL)
assert.Equal(t, "", news[0].Author)
assert.Equal(t, "<a href=\"http://www.ugcleague.com/\"> </a> Prepare yourself, the UGC League Winter Season is about to start! Join the thousands of teams that played last season for some competitive TF2 action! The first week of matches starts <b>January 23rd for Highlander, January 25th for 6v6 and January 27th for 4v4.</b> UGC has divisions across North America...", news[0].Contents)
assert.Equal(t, "TF2 Blog", news[0].FeedLabel)
assert.Equal(t, int64(1483470600), news[0].Date)
assert.Equal(t, "tf2_blog", news[0].FeedName)
}