-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathokra_test.go
51 lines (40 loc) · 1.41 KB
/
okra_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
package okra_test
import (
"os"
"testing"
okra "github.com/Uchencho/OkraGo"
)
const (
baseurl = "https://api.okra.ng/sandbox/v1"
succeed = "\u2713"
failed = "\u2717"
)
var token = os.Getenv("OKRA_TOKEN")
func TestInitializeOkra(t *testing.T) {
const errorMessage = "Token and Base url is needed to call this Function"
_, err := okra.New("", baseurl)
if err == nil {
t.Fatalf("\t%s\tTest NewClient:\tGot Error: %v, Expected %v", failed, nil, errorMessage)
}
t.Logf("\t%s\tTest NewClient:\tShould have returned error %v", succeed, err)
}
func TestRetrieveAuth(t *testing.T) {
okraClient, err2 := okra.New(token, baseurl)
if err2 != nil {
body, err := okraClient.RetrieveAuth()
if err != nil || body.StatusCode != 200 {
t.Fatalf("\t%s\tTest RetrieveAuth:\tGot Error: %v, and statuscode is : %v, Expected %v", failed, err, body.StatusCode, nil)
}
t.Logf("\t%s\tTest RetrieveAuth:\tShould have returned no errors.", succeed)
}
}
func TestTransactionByCustomerID(t *testing.T) {
okraClient, _ := okra.New(token, baseurl)
cID := "5e9d5dd3471ff50f735ad68a"
body, err := okraClient.TransactionByCustomer("1", "30", cID)
if err != nil || body.StatusCode != 200 {
t.Fatalf("\t%s\tTest TransactionByCustomer:\tGot Error: %v, and statuscode : %v, Expected %v", failed, err, body.StatusCode, nil)
}
t.Logf("\t%s\tTest TransactionByCustomer:\tShould have returned no errors.", succeed)
}
// To Do: Use mock tests