-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.go
57 lines (45 loc) · 1.25 KB
/
client_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
52
53
54
55
56
57
package client_test
import (
"os"
"testing"
client "github.com/charliemaiors/satispay-client"
log "github.com/sirupsen/logrus"
)
var validSatisClient, satisClient *client.Client
var err error
func init() {
if token := os.Getenv("BEARER_TOKEN"); token == "" {
panic("In order to run tests please set environment variable BEARER_TOKEN with valid satispay token")
} else {
validSatisClient, err = client.NewClient(token, false)
if err != nil {
panic(err)
}
}
satisClient, err = client.NewClient("sdhofdhafshduiahufdafhsudodfshauoo", false)
if err != nil {
panic(err)
}
log.SetLevel(log.DebugLevel)
}
func TestNewClientError(test *testing.T) {
_, err := client.NewClient("", false)
if err == nil {
test.Fatal("Error is not nil but token is empty, test failed")
}
test.Logf("Error is %v", err)
}
func TestClientBearer(test *testing.T) {
valid := satisClient.CheckBearer()
if valid {
test.Fatalf("Expecting random generated token invalid but instead is %v", valid)
}
test.Logf("Token is valid %v", valid)
}
func TestClientBearerValid(test *testing.T) {
valid := validSatisClient.CheckBearer()
if !valid {
test.Fatalf("Expecting random generated token invalid but instead is %v", valid)
}
test.Logf("Token is valid %v", valid)
}