-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpermlinks_test.go
More file actions
51 lines (36 loc) · 977 Bytes
/
permlinks_test.go
File metadata and controls
51 lines (36 loc) · 977 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
45
46
47
48
49
50
51
package gowandbox
import (
"context"
"strings"
"testing"
"time"
)
func TestGetPermLink(t *testing.T) {
result, err := GetPermLink("ia8loUVGVV8widMw", context.Background())
if err != nil {
t.Error(err.Error())
}
t.Logf("ISO-8601 time - %v", result.Parameter.CreatedAt)
}
func TestGetPermLinkTimeoutError(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Millisecond)
defer cancel()
_, err := GetPermLink("ia8loUVGVV8widMw", ctx)
if err == nil {
t.Error("Got no error, but was expecting one!")
}
if !strings.Contains(err.Error(), "context deadline exceeded") {
t.Fatal(err.Error())
}
t.Log("Request timed out, as expected")
}
func TestGetPermLinkBadLinkError(t *testing.T) {
_, err := GetPermLink("abc", context.Background())
if err == nil {
t.Error("Got no error, but was expecting one!")
}
if !strings.Contains(err.Error(), "500 Error") {
t.Fatal(err.Error())
}
t.Log("Got 500 error, as expected")
}