-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathverify_test.go
35 lines (30 loc) · 919 Bytes
/
verify_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
package thingscloud
import (
"fmt"
"testing"
)
func TestClient_Verify(t *testing.T) {
t.Run("Success", func(t *testing.T) {
t.Parallel()
server := fakeServer(fakeResponse{200, "verify-success.json"})
defer server.Close()
c := New(fmt.Sprintf("http://%s", server.Listener.Addr().String()), "[email protected]", "")
v, err := c.Verify()
if err != nil {
t.Fatalf("Expected Verification to succeed, but didn't: %q", err.Error())
}
if v.Status != AccountStatusActive {
t.Errorf("Expected account to be %q, but got %q", AccountStatusActive, v.Status)
}
})
t.Run("Error", func(t *testing.T) {
t.Parallel()
server := fakeServer(fakeResponse{401, "error.json"})
defer server.Close()
c := New(fmt.Sprintf("http://%s", server.Listener.Addr().String()), "[email protected]", "")
_, err := c.Verify()
if err == nil {
t.Error("Expected Verification to fail, but didn't")
}
})
}