client_test.go

This commit is contained in:
LAZHCM10161 2015-10-15 12:52:16 +07:00
parent 54034e1d72
commit 93d412d46f
3 changed files with 24 additions and 0 deletions

7
.travis.yml Normal file
View File

@ -0,0 +1,7 @@
language: go
go:
- 1.4
install:
- export PATH=$PATH:$HOME/gopath/bin
script:
- go test -v

View File

@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"errors"
"bytes" "bytes"
"time" "time"
"fmt" "fmt"
@ -12,6 +13,10 @@ import (
// NewClient returns new Client struct // NewClient returns new Client struct
func NewClient(clientID string, secret string, APIBase string) (*Client, error) { func NewClient(clientID string, secret string, APIBase string) (*Client, error) {
if clientID == "" || secret == "" || APIBase == "" {
return &Client{}, errors.New("ClientID, Secret and APIBase are required to create a Client")
}
return &Client{ return &Client{
&http.Client{}, &http.Client{},
clientID, clientID,

12
client_test.go Normal file
View File

@ -0,0 +1,12 @@
package paypalsdk
import (
"testing"
)
func TestNewClient(t *testing.T) {
_, err := NewClient("", "", "")
if err == nil {
t.Errorf("All arguments are required in NewClient()")
}
}