-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtweet_test.go
72 lines (69 loc) · 1.42 KB
/
tweet_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
package main
import (
"testing"
"github.com/dghubble/go-twitter/twitter"
)
func TestHandleEntities(t *testing.T) {
type fields struct {
Tweet twitter.Tweet
}
type args struct {
dir string
}
tests := []struct {
name string
fields fields
args args
shouldErr bool
}{
{
"No media returns nil",
fields{twitter.Tweet{ExtendedEntities: &twitter.ExtendedEntity{Media: nil}}},
args{"foo"},
false,
},
{
"Photo downloads the photo",
fields{
twitter.Tweet{
ExtendedEntities: &twitter.ExtendedEntity{
Media: []twitter.MediaEntity{
{Type: "photo", MediaURL: "https://static.wilkins.tech/twitback/test.png"},
},
},
},
},
args{"test_fixtures"},
false,
},
{
"Video downloads the video",
fields{
twitter.Tweet{
ExtendedEntities: &twitter.ExtendedEntity{
Media: []twitter.MediaEntity{
{
Type: "video",
VideoInfo: twitter.VideoInfo{
Variants: []twitter.VideoVariant{{URL: "https://static.wilkins.tech/twitback/test.mp4"}},
},
},
},
},
},
},
args{"test_fixtures"},
false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tw := &tweet{
Tweet: tt.fields.Tweet,
}
if err := tw.HandleEntities(tt.args.dir); (err != nil) != tt.shouldErr {
t.Errorf("tweet.HandleEntities() failed, error: %v, shouldErr: %v", err, tt.shouldErr)
}
})
}
}