From 93d412d46f66747c5889571591fb2a15fe95b985 Mon Sep 17 00:00:00 2001 From: LAZHCM10161 Date: Thu, 15 Oct 2015 12:52:16 +0700 Subject: [PATCH] client_test.go --- .travis.yml | 7 +++++++ client.go | 5 +++++ client_test.go | 12 ++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 .travis.yml create mode 100644 client_test.go diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1b4ade0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: go +go: + - 1.4 +install: + - export PATH=$PATH:$HOME/gopath/bin +script: + - go test -v diff --git a/client.go b/client.go index b523f06..e603c21 100644 --- a/client.go +++ b/client.go @@ -4,6 +4,7 @@ import ( "encoding/json" "io/ioutil" "net/http" + "errors" "bytes" "time" "fmt" @@ -12,6 +13,10 @@ import ( // NewClient returns new Client struct 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{ &http.Client{}, clientID, diff --git a/client_test.go b/client_test.go new file mode 100644 index 0000000..6f42818 --- /dev/null +++ b/client_test.go @@ -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()") + } +}