First major code push

Preparing for version 0.1.0
Contains a real README, the test framework, and the API implementation
This commit is contained in:
densestvoid
2020-07-29 22:20:57 -04:00
parent d015059acc
commit 31885d2726
32 changed files with 4555 additions and 2 deletions

49
client_test.go Normal file
View File

@ -0,0 +1,49 @@
package groupme
import (
"net/http"
"testing"
"github.com/stretchr/testify/suite"
)
type ClientSuite struct{ APISuite }
func (s *ClientSuite) SetupSuite() {
serverMux := http.NewServeMux()
serverMux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
_, err := w.Write([]byte("error"))
s.Require().NoError(err)
})
s.handler = serverMux
s.setupSuite()
}
func (s *ClientSuite) SetupTest() {
s.client = NewClient("")
s.Require().NotNil(s.client)
s.client.endpointBase = s.addr
}
func (s *ClientSuite) TestClient_Close() {
s.Assert().NoError(s.client.Close())
}
func (s *ClientSuite) TestClient_do_DoError() {
req, err := http.NewRequest("", "", nil)
s.Require().NoError(err)
s.Assert().Error(s.client.do(req, struct{}{}))
}
func (s *ClientSuite) TestClient_do_UnmarshalError() {
req, err := http.NewRequest("GET", s.addr, nil)
s.Require().NoError(err)
s.Assert().Error(s.client.do(req, struct{}{}))
}
func TestClientSuite(t *testing.T) {
suite.Run(t, new(ClientSuite))
}