This repository was archived by the owner on Nov 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathuser_test.go
84 lines (77 loc) · 2.29 KB
/
user_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (c) 2012 Brian Hetro <[email protected]>
// Use of this source code is governed by the ISC
// license that can be found in the LICENSE file.
package adn
import (
"encoding/json"
"testing"
)
var testUserData = []byte(`
{
"avatar_image":{
"height":200,
"url":"https:\/\/d2rfichhc2fb9n.cloudfront.net\/image\/4\/zBIezrirTTAVL1JQFy9mgA8RePruklFAwH9TNCqvR3fxoeGPC-JnYYN3yvkMT907ZvnrEA7HWt3Nk8kBBPmnwa78iRo3HArocVxx97_zjfL5nv-vVvjG-63zeQeSKH1iPdGuxPF70NBajBFy2qkCXGDX44A",
"width":200
},
"counts":{
"followers":5239,
"following":455,
"posts":3121,
"stars":216
},
"cover_image":{
"height":456,
"url":"https:\/\/d2rfichhc2fb9n.cloudfront.net\/image\/4\/iV3sRFel7xEjDK7hCB9R0xgIFAH7fQEtmq_KmotfjaDfuOEPbfcy2go0g5_fees1lwanOhzqz-BNSyC9bF09pHQryBA-Gsi_3Z_Gz81IZMibsiFaZ4TajDFDhoBFxE6H4TGXJZxdW1ZGA0VmZQN0n6MsEdM",
"width":1103
},
"created_at":"2012-08-03T01:17:14Z",
"description":{
"entities":{
"hashtags":[
],
"links":[
{
"len":7,
"pos":12,
"text":"App.net",
"url":"http:\/\/App.net"
},
{
"len":18,
"pos":28,
"text":"daltoncaldwell.com",
"url":"http:\/\/daltoncaldwell.com"
}
],
"mentions":[
]
},
"html":"<span itemscope=\"https:\/\/app.net\/schemas\/Post\">Founder\/CEO <a href=\"http:\/\/App.net\">App.net<\/a> \r\nBlog: <a href=\"http:\/\/daltoncaldwell.com\">daltoncaldwell.com<\/a><\/span>",
"text":"Founder\/CEO App.net \r\nBlog: daltoncaldwell.com"
},
"follows_you":false,
"id":"1",
"is_follower":true,
"is_following":false,
"is_muted":false,
"locale":"en_US",
"name":"Dalton Caldwell",
"timezone":"America\/Los_Angeles",
"type":"human",
"username":"dalton",
"you_follow":true,
"you_muted":false
}`)
func TestUserDecode(t *testing.T) {
u := &User{}
if err := json.Unmarshal(testUserData, u); err != nil {
t.Error("json.Unmarshal(testUserData)", err)
}
}
func TestUserGet(t *testing.T) {
// Not authenticated. This should fail.
_, err := GetUser("", "@whee")
if err == nil {
t.Error("unauthenticated GetUser() should have failed", err)
}
}