-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsteam_test.go
More file actions
60 lines (43 loc) · 2.2 KB
/
Copy pathsteam_test.go
File metadata and controls
60 lines (43 loc) · 2.2 KB
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
package scraper
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
var steamKey = os.Getenv("STEAM_API_KEY")
const robinAvatar = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4.jpg"
const robinPUrl = "http://steamcommunity.com/id/robinwalker/"
func TestSteamPlayers(t *testing.T) {
SetSteamApiKey(steamKey)
playerInfo, playErr := GetPlayersInfo([]string{"76561197960435530", "76561198067132047"})
assert.Nil(t, playErr, "There is an error!")
assert.NotNil(t, playerInfo["76561197960435530"], "The id should be available!")
assert.NotNil(t, playerInfo["76561198067132047"], "The id should be available!")
// vars
visibility := playerInfo["76561197960435530"].Visibility
realName := playerInfo["76561197960435530"].Realname
avatar := playerInfo["76561197960435530"].Avatar
pState := playerInfo["76561197960435530"].Personastate
name := playerInfo["76561197960435530"].Name
pUrl := playerInfo["76561197960435530"].Profileurl
// tests
assert.Equal(t, PersonaStateOffline, pState, "wtf is he doing not offline?")
assert.Equal(t, "Robin Walker", realName, "Name should be Robin Walker")
assert.Equal(t, robinAvatar, avatar, "Avatar should be "+robinAvatar)
assert.Equal(t, "Offline", pState.String(), "yo, hes online!")
assert.Equal(t, robinPUrl, pUrl, "no comments")
assert.Equal(t, "public", visibility, "Profile visibility should be public")
assert.Equal(t, "Robin", name, "Name should be Robin")
}
func TestSteamPlayer(t *testing.T) {
SetSteamApiKey(steamKey)
playerInfo, playErr := GetPlayerInfo("76561197960435530")
assert.Nil(t, playErr, "There is an error!")
assert.Equal(t, PersonaStateOffline, playerInfo.Personastate, "wtf is he doing not offline?")
assert.Equal(t, "Robin Walker", playerInfo.Realname, "Name should be Robin Walker")
assert.Equal(t, robinAvatar, playerInfo.Avatar, "Avatar should be "+robinAvatar)
assert.Equal(t, "Offline", playerInfo.Personastate.String(), "yo, hes online!")
assert.Equal(t, robinPUrl, playerInfo.Profileurl, "no comments")
assert.Equal(t, "public", playerInfo.Visibility, "Profile visibility should be public")
assert.Equal(t, "Robin", playerInfo.Name, "Name should be Robin")
}