-
Notifications
You must be signed in to change notification settings - Fork 2
/
binchecker_test.go
47 lines (39 loc) · 919 Bytes
/
binchecker_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
package binchecker
import (
"fmt"
"log"
"os"
"testing"
)
func TestMain(m *testing.M) {
os.Exit(m.Run())
}
func TestBinCheckerWithoutEnvVar(t *testing.T) {
backupEnv := ""
currentEnv, ok := os.LookupEnv("PROMPTAPI_TOKEN")
if ok {
backupEnv = currentEnv
os.Unsetenv("PROMPTAPI_TOKEN")
}
r := new(Result)
got := BinChecker("1234", r)
if got.Error() != "You need to set PROMPTAPI_TOKEN environment variable" {
t.Errorf("got: %v", got)
}
if ok {
os.Setenv("PROMPTAPI_TOKEN", backupEnv)
}
}
func ExampleBinChecker() {
result := new(Result)
if err := BinChecker("302596", result); err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", result)
fmt.Printf("BankName: %s\n", result.BankName)
fmt.Printf("Country: %s\n", result.Country)
fmt.Printf("URL: %s\n", result.URL)
fmt.Printf("Type: %s\n", result.Type)
fmt.Printf("Scheme: %s\n", result.Scheme)
fmt.Printf("Bin: %s\n", result.Bin)
}