-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtypes_test.go
More file actions
44 lines (40 loc) · 792 Bytes
/
types_test.go
File metadata and controls
44 lines (40 loc) · 792 Bytes
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
package circle
import (
"encoding/json"
"net/url"
"testing"
"time"
)
func TestCircleDuration(t *testing.T) {
s := "345"
var cd CircleDuration
err := json.Unmarshal([]byte(s), &cd)
if err != nil {
t.Fatal(err)
}
expected := CircleDuration(345 * time.Millisecond)
if cd != expected {
t.Fatal(cd)
}
}
func TestURL(t *testing.T) {
s := "\"https://foo.com\""
var u URL
err := json.Unmarshal([]byte(s), &u)
if err != nil {
t.Fatal(err)
}
if u.Scheme != "https" {
t.Fatalf("expected scheme to be 'https', url was %s", u)
}
}
func TestString(t *testing.T) {
u, err := url.Parse("https://foo.com")
if err != nil {
t.Fatal(err)
}
cu := URL{u}
if cu.String() != "https://foo.com" {
t.Fatalf("expected cu.String() to be https://foo.com, was %s", cu.String())
}
}