-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgraph_test.go
60 lines (49 loc) · 1.61 KB
/
graph_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package facebook
import "testing"
func TestNewGraph(t *testing.T) {
graph := new(Graph).SetVersion(``)
url := graph.GenerateURL(`/me`)
expectedURL := `https://graph.facebook.com/v2.10/me`
if url != expectedURL {
t.Fatalf(`Expected %s, BUT got %s`, expectedURL, url)
}
}
func TestGetVersion(t *testing.T) {
graph := new(Graph).SetVersion(``)
if graph.GetVersion() != `v2.10` {
t.Fatalf(`Expected "v2.10", BUT got "%s"`, graph.GetVersion())
}
}
func TestGetGraphURL(t *testing.T) {
graph := new(Graph).SetVersion(``)
if graph.GetGraphURL() != `https://graph.facebook.com` {
t.Fatalf(`Expected "https://graph.facebook.com", BUT got "%s"`, graph.GetGraphURL())
}
}
func TestGenerateURL(t *testing.T) {
version := `v2.10`
graph := new(Graph).SetVersion(version)
url := graph.GenerateURL(`/me`)
expectedURL := `https://graph.facebook.com/` + version + `/me`
if url != expectedURL {
t.Fatalf(`Expected "%s", BUT got "%s"`, expectedURL, url)
}
}
func TestGenerateURLWithFields(t *testing.T) {
version := `v2.10`
graph := new(Graph).SetVersion(version)
url := graph.GenerateURLWithFields(`/me`, `id,name`)
expectedURL := `https://graph.facebook.com/` + version + `/me?fields=id,name`
if url != expectedURL {
t.Fatalf(`Expected "%s", BUT got "%s"`, expectedURL, url)
}
}
func TestGenerateRawURL(t *testing.T) {
version := `v2.10`
graph := new(Graph).SetVersion(version)
url := graph.GenerateRawURL(`/me`, `?fields=id,name,birthday`)
expectedURL := `https://graph.facebook.com/` + version + `/me?fields=id,name,birthday`
if url != expectedURL {
t.Fatalf(`Expected "%s", BUT got "%s"`, expectedURL, url)
}
}