forked from adlio/trello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrello_test.go
41 lines (32 loc) · 812 Bytes
/
trello_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
package trello
import (
"testing"
"time"
)
func TestIDToTimeWithBlankString(t *testing.T) {
t1, err := IDToTime("")
if err != nil {
t.Error(err)
}
if !t1.IsZero() {
t.Error("IDToTime should return a zero-value time for empty strings.")
}
}
func TestIDToStringWithKnownTime(t *testing.T) {
t1, err := IDToTime("5865ba842057a239b32d38c0")
if err != nil {
t.Error(err)
}
// Convert to UTC for consistent comparisons regardless of which
// time zone the test computer is in.
t1 = t1.UTC()
if t1.Format(time.RFC3339) != "2016-12-30T01:38:12Z" {
t.Errorf("Expected '2016-12-30T01:38:12Z', got '%s'", t1.Format(time.RFC3339))
}
}
func TestIDToStringWithInvalidTime(t *testing.T) {
_, err := IDToTime("tooshort")
if err == nil {
t.Error("ID 'tooshort' should produce an error.")
}
}