f92a8a7a86
Contexts have been added to all API requests, in addition to other linting fixes
76 lines
1.3 KiB
Go
Executable File
76 lines
1.3 KiB
Go
Executable File
// Package groupme defines a client capable of executing API commands for the GroupMe chat service
|
|
package groupme
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
)
|
|
|
|
type JSONSuite struct {
|
|
suite.Suite
|
|
}
|
|
|
|
func (s *JSONSuite) TestGroup_GetMemberByUserID_Match() {
|
|
m := Member{
|
|
UserID: "123",
|
|
}
|
|
|
|
g := Group{
|
|
Members: []*Member{&m},
|
|
}
|
|
|
|
actual := g.GetMemberByUserID("123")
|
|
|
|
s.Require().NotNil(actual)
|
|
s.Assert().Equal(m, *actual)
|
|
}
|
|
|
|
func (s *JSONSuite) TestGroup_GetMemberByUserID_NoMatch() {
|
|
g := Group{
|
|
Members: []*Member{},
|
|
}
|
|
|
|
actual := g.GetMemberByUserID("123")
|
|
|
|
s.Require().Nil(actual)
|
|
}
|
|
|
|
func (s *JSONSuite) TestGroup_GetMemberByNickname_Match() {
|
|
m := Member{
|
|
Nickname: "Test User",
|
|
}
|
|
|
|
g := Group{
|
|
Members: []*Member{&m},
|
|
}
|
|
|
|
actual := g.GetMemberByNickname("Test User")
|
|
|
|
s.Require().NotNil(actual)
|
|
s.Assert().Equal(m, *actual)
|
|
}
|
|
|
|
func (s *JSONSuite) TestGroup_GetMemberByNickname_NoMatch() {
|
|
g := Group{
|
|
Members: []*Member{},
|
|
}
|
|
|
|
actual := g.GetMemberByNickname("Test User")
|
|
|
|
s.Require().Nil(actual)
|
|
}
|
|
|
|
func (s *JSONSuite) TestMarshal_NoError() {
|
|
s.Assert().Equal("{}", marshal(&struct{}{}))
|
|
}
|
|
|
|
func (s *JSONSuite) TestMarshal_Error() {
|
|
var c chan struct{}
|
|
s.Assert().Equal("", marshal(c))
|
|
}
|
|
|
|
func TestJSONSuite(t *testing.T) {
|
|
suite.Run(t, new(JSONSuite))
|
|
}
|