This repository has been 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
/
post_test.go
122 lines (113 loc) · 3.43 KB
/
post_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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright (c) 2012 Brian Hetro <whee@smaertness.net>
// 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 testPostData = []byte(`
{
"created_at":"2012-09-21T00:13:05Z",
"entities":{
"hashtags":[
],
"links":[
{
"len":21,
"pos":51,
"text":"http:\/\/tcrn.ch\/UlUQZv",
"url":"http:\/\/tcrn.ch\/UlUQZv"
},
{
"len":20,
"pos":74,
"text":"http:\/\/bit.ly\/SG83ej",
"url":"http:\/\/bit.ly\/SG83ej"
}
],
"mentions":[
]
},
"html":"<span itemscope=\"https:\/\/app.net\/schemas\/Post\">Nope, nothing ironic about this rolling out today: <a href=\"http:\/\/tcrn.ch\/UlUQZv\">http:\/\/tcrn.ch\/UlUQZv<\/a>\n\n<a href=\"http:\/\/bit.ly\/SG83ej\">http:\/\/bit.ly\/SG83ej<\/a><\/span>",
"id":"489932",
"machine_only":false,
"num_replies":7,
"num_reposts":4,
"num_stars":1,
"source":{
"client_id":"caYWDBvjwt2e9HWMm6qyKS6KcATHUkzQ",
"link":"https:\/\/alpha.app.net",
"name":"Alpha"
},
"text":"Nope, nothing ironic about this rolling out today: http:\/\/tcrn.ch\/UlUQZv\n\nhttp:\/\/bit.ly\/SG83ej",
"thread_id":"489932",
"user":{
"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
},
"you_reposted":false,
"you_starred":false
}`)
func TestPostDecode(t *testing.T) {
p := &Post{}
if err := json.Unmarshal(testPostData, p); err != nil {
t.Error("json.Unmarshal(testPostData)", err)
}
}
func TestPostGet(t *testing.T) {
if _, err := GetPost("", "511604"); err != nil {
t.Error("getting post", err)
}
}