-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
ready_test.go
32 lines (26 loc) · 937 Bytes
/
ready_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
package netbox
import (
"net/http"
"testing"
"gopkg.in/h2non/gock.v1"
)
func TestNetboxReady(t *testing.T) {
defer gock.Off() // Flush pending mocks after test execution
gock.New("https://example.org/api/ipam/ip-addresses/").MatchParams(
map[string]string{"limit": "1"}).Reply(200)
nb := Netbox{Url: "https://example.org/api/ipam/ip-addresses", Token: "s3kr3tt0ken", Client: &http.Client{}}
ready := nb.Ready()
if !ready {
t.Errorf("Expected ready be %v, got %v", true, ready)
}
}
func TestNetboxNotReady(t *testing.T) {
defer gock.Off() // Flush pending mocks after test execution
gock.New("https://example.org/api/ipam/ip-addresses/").MatchParams(
map[string]string{"limit": "1"}).Reply(403)
nb := Netbox{Url: "https://example.org/api/ipam/ip-addresses", Token: "s3kr3tt0ken", Client: &http.Client{}}
not_ready := nb.Ready()
if not_ready {
t.Errorf("Expected ready to be %v, got %v", false, not_ready)
}
}