@@ -8,109 +8,71 @@ import (
8
8
)
9
9
10
10
func TestCoverURL (t * testing.T ) {
11
- game := createFullfilledGame ()
11
+ game := Game { Cover : Cover { Id : 1 , ImageID : "lich_king" }}
12
12
result := game .CoverURL ()
13
- expected := "https://images.igdb.com/igdb/image/upload/t_cover_big/thisIsACoverID .png"
13
+ expected := "https://images.igdb.com/igdb/image/upload/t_cover_big/lich_king .png"
14
14
15
15
if result != expected {
16
- t .Errorf ("Unexpected coverUrl : expected:%s, got:%s" , expected , result )
16
+ t .Errorf ("Unexpected CoverUrl() : expected:%s, got:%s" , expected , result )
17
17
}
18
18
}
19
19
20
- func TestNotionPlatformsFullfilled (t * testing.T ) {
21
- game := createFullfilledGame ()
22
- result := game .NotionPlatforms ()
23
- expected := []notionapi.Option {
24
- {Name : "Wii" },
25
- {Name : "PC" },
20
+ func TestNotionPlatforms (t * testing.T ) {
21
+ var game Game = Game {}
22
+ var tests = []struct {
23
+ platforms Platforms
24
+ expected []notionapi.Option
25
+ }{
26
+ {platforms : Platforms {}, expected : []notionapi.Option {}},
27
+ {platforms : Platforms {{Id : 1 , Name : "Wii" }, {Id : 2 , Name : "PC" }}, expected : []notionapi.Option {{Name : "Wii" }, {Name : "PC" }}},
26
28
}
27
29
28
- if ! reflect .DeepEqual (result , expected ) {
29
- t .Errorf ("Unexpected notionPlatforms: expected:%s, got:%s" , expected , result )
30
- }
31
- }
32
-
33
- func TestNotionPlatformsEmpty (t * testing.T ) {
34
- game := createFullfilledGame ()
35
- game .Platforms = nil
36
-
37
- result := game .NotionPlatforms ()
38
- expected := []notionapi.Option {}
30
+ for _ , tt := range tests {
31
+ game .Platforms = tt .platforms
32
+ result := game .NotionPlatforms ()
39
33
40
- if ! reflect .DeepEqual (result , expected ) {
41
- t .Errorf ("Unexpected notionPlatforms: expected:%s, got:%s" , expected , result )
34
+ if ! reflect .DeepEqual (result , tt .expected ) {
35
+ t .Errorf ("Unexpected NotionPlatforms(): expected:%s, got:%s" , tt .expected , result )
36
+ }
42
37
}
43
38
}
44
39
45
- func TestNotionGenresFullfilled (t * testing.T ) {
46
- game := createFullfilledGame ()
47
- result := game .NotionGenres ()
48
- expected := []notionapi.Option {
49
- {Name : "Roleplay" },
50
- {Name : "Shooter" },
40
+ func TestNotionGenres (t * testing.T ) {
41
+ var game Game = Game {}
42
+ var tests = []struct {
43
+ genres Genres
44
+ expected []notionapi.Option
45
+ }{
46
+ {genres : Genres {}, expected : []notionapi.Option {}},
47
+ {genres : Genres {{Id : 5 , Name : "Roleplay" }, {Id : 6 , Name : "Shooter" }}, expected : []notionapi.Option {{Name : "Roleplay" }, {Name : "Shooter" }}},
51
48
}
52
49
53
- if ! reflect .DeepEqual (result , expected ) {
54
- t .Errorf ("Unexpected notionGenres: expected:%s, got:%s" , expected , result )
55
- }
56
- }
57
-
58
- func TestNotionGenresEmpty (t * testing.T ) {
59
- game := createFullfilledGame ()
60
- game .Genres = nil
50
+ for _ , tt := range tests {
51
+ game .Genres = tt .genres
52
+ result := game .NotionGenres ()
61
53
62
- result := game .NotionGenres ()
63
- expected := []notionapi.Option {}
64
-
65
- if ! reflect .DeepEqual (result , expected ) {
66
- t .Errorf ("Unexpected notionGenres: expected:%s, got:%s" , expected , result )
54
+ if ! reflect .DeepEqual (result , tt .expected ) {
55
+ t .Errorf ("Unexpected NotionGenres(): expected:%s, got:%s" , tt .expected , result )
56
+ }
67
57
}
68
58
}
69
59
70
- func TestNotionFranchisesFullfilled (t * testing.T ) {
71
- game := createFullfilledGame ()
72
- result := game .NotionFranchises ()
73
- expected := []notionapi.Option {
74
- {Name : "An awesome franchise" },
75
- {Name : "Another awesome franchise" },
76
- }
77
-
78
- if ! reflect .DeepEqual (result , expected ) {
79
- t .Errorf ("Unexpected notionFranchises: expected:%s, got:%s" , expected , result )
60
+ func TestNotionFranchises (t * testing.T ) {
61
+ var game Game = Game {}
62
+ var tests = []struct {
63
+ franchises Franchises
64
+ expected []notionapi.Option
65
+ }{
66
+ {franchises : Franchises {}, expected : []notionapi.Option {}},
67
+ {franchises : Franchises {{Id : 3 , Name : "An awesome franchise" }, {Id : 4 , Name : "Another awesome franchise" }}, expected : []notionapi.Option {{Name : "An awesome franchise" }, {Name : "Another awesome franchise" }}},
80
68
}
81
- }
82
69
83
- func TestNotionFranchisesEmpty ( t * testing. T ) {
84
- game := createFullfilledGame ()
85
- game . Franchises = nil
70
+ for _ , tt := range tests {
71
+ game . Franchises = tt . franchises
72
+ result := game . NotionFranchises ()
86
73
87
- result := game .NotionFranchises ()
88
- expected := []notionapi.Option {}
89
-
90
- if ! reflect .DeepEqual (result , expected ) {
91
- t .Errorf ("Unexpected notionFranchises: expected:%s, got:%s" , expected , result )
92
- }
93
- }
94
- func createFullfilledGame () Game {
95
- return Game {
96
- Id : 1 ,
97
- Name : "This is a fullfilled game" ,
98
- ReleaseDate : 861199200 ,
99
- Platforms : Platforms {
100
- {Id : 1 , Name : "Wii" },
101
- {Id : 2 , Name : "PC" },
102
- },
103
- Franchises : Franchises {
104
- {Id : 3 , Name : "An awesome franchise" },
105
- {Id : 4 , Name : "Another awesome franchise" },
106
- },
107
- Genres : Genres {
108
- {Id : 5 , Name : "Roleplay" },
109
- {Id : 6 , Name : "Shooter" },
110
- },
111
- Cover : Cover {
112
- Id : 7 ,
113
- ImageID : "thisIsACoverID" ,
114
- },
74
+ if ! reflect .DeepEqual (result , tt .expected ) {
75
+ t .Errorf ("Unexpected NotionFranchises(): expected:%s, got:%s" , tt .expected , result )
76
+ }
115
77
}
116
78
}
0 commit comments