-
Notifications
You must be signed in to change notification settings - Fork 0
/
integration_test.go
89 lines (74 loc) · 2.15 KB
/
integration_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
//go:build integration
// +build integration
package codeforces
// Currently used to verify the api endpoints are hit.
// Still really early stages
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type IntegrationSuite struct {
suite.Suite
c Client
}
func (suite *IntegrationSuite) SetupTest() {
apiKey := os.Getenv("CF_API_KEY")
apiSecret := os.Getenv("CF_API_SECRET")
suite.c = *NewClient(apiKey, apiSecret)
}
func TestIntegration(t *testing.T) {
suite.Run(t, new(IntegrationSuite))
}
func (suite *IntegrationSuite) TestInfo() {
handle := "tourist"
resp, err := suite.c.User.Info([]string{handle})
assert.Nil(suite.T(), err)
assert.NotNil(suite.T(), resp)
first := (*resp)[0]
assert.Equal(suite.T(), handle, first.Handle)
}
func (suite *IntegrationSuite) TestComments() {
resp, err := suite.c.Blog.Comments(79)
assert.Nil(suite.T(), err)
assert.NotNil(suite.T(), resp)
}
func (suite *IntegrationSuite) TestHacks() {
resp, err := suite.c.Contest.Hacks(566)
assert.Nil(suite.T(), err)
assert.NotNil(suite.T(), resp)
}
func (suite *IntegrationSuite) TestEntryByID() {
resp, err := suite.c.Blog.EntryById(79)
assert.Nil(suite.T(), err)
assert.NotNil(suite.T(), resp)
assert.Equal(suite.T(), 79, resp.ID)
}
func (suite *IntegrationSuite) TestFriends() {
suite.showEmptyVariablesWarning()
resp, err := suite.c.User.Friends(false)
assert.Nil(suite.T(), err)
assert.NotNil(suite.T(), resp)
}
func (suite *IntegrationSuite) showEmptyVariablesWarning() {
apiKey := os.Getenv("CF_API_KEY")
apiSecret := os.Getenv("CF_API_SECRET")
emptyVariableMessage := "%s is empty, TestFriends will probably fail"
if apiKey == "" {
suite.T().Logf(emptyVariableMessage, "apiKey")
}
if apiSecret == "" {
suite.T().Logf(emptyVariableMessage, "apiSecret")
}
}
func (suite *IntegrationSuite) TestStatus() {
resp, err := suite.c.Contest.StatusWithHandle(566, 1, 5, "tourist")
assert.Nil(suite.T(), err)
assert.NotNil(suite.T(), resp)
}
func (suite *IntegrationSuite) TestStandings() {
resp, err := suite.c.Contest.Standings(566, 1, 5, []string{}, false)
assert.Nil(suite.T(), err)
assert.NotNil(suite.T(), resp)
}