-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgomusicbrainz_test.go
127 lines (102 loc) · 3.06 KB
/
gomusicbrainz_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
123
124
125
126
127
package gomusicbrainz
import (
"testing"
"github.com/davecgh/go-spew/spew"
"github.com/stretchr/testify/assert"
)
var (
recordingMBID = "2cfad207-3f55-4aec-8120-86cf66e34d59"
workMBID = "b38119e8-260f-372c-a1ca-653d02b5577c"
isrcID = "USAT29900609"
iswcID = "T-070.080.286-3"
artistMBID = "678d88b2-87b0-403b-b63d-5da7465aecc3"
)
func TestGetAnythingWithoutConfigSetupWillResultInError(t *testing.T) {
_, err := GetRecording("does_not_matter")
t.Log(err)
assert.True(t, err != nil, "Error should be raised!")
}
func TestWhenGettingRecordingWithoutInputWillResultInError(t *testing.T) {
Setup()
_, err := GetRecording("")
t.Log(err)
assert.True(t, err != nil, err, "Error should be raised!")
}
func TestGetRecordingWithValidMBID(t *testing.T) {
Setup()
result, err := GetRecording(recordingMBID)
if err != nil {
t.Log(err.Error())
t.Fail()
}
assert.True(t, err == nil, "Error should not be raised: ")
assert.True(t, result != nil, "Result should not be nil")
assert.Equal(t, recordingMBID, result.ID, "Expected recording MBID is different")
printResult(result)
}
func TestGetWorkWithValidMBID(t *testing.T) {
Setup()
result, err := GetWork(workMBID)
if err != nil {
t.Log(err.Error())
t.Fail()
}
assert.True(t, err == nil, "Error should not be raised: ")
assert.True(t, result != nil, "Result should not be nil")
assert.Equal(t, workMBID, result.ID, "Expected recording MBID is different")
printResult(result)
}
func TestGetRecordingsByISRCSWithValidISRC(t *testing.T) {
Setup()
result, err := GetRecordingsByISRC(isrcID)
if err != nil {
t.Log(err.Error())
t.Fail()
}
assert.True(t, err == nil, "Error should not be raised: ")
assert.True(t, result != nil, "Result should not be nil")
assert.Equal(t, isrcID, result.ISRCID, "Expected recording ISRC is different")
printResult(result)
}
func TestGetWorksByISWCSWithValidISWC(t *testing.T) {
Setup()
result, err := GetWorksByISWC(iswcID)
if err != nil {
t.Log(err.Error())
t.Fail()
}
assert.True(t, err == nil, "Error should not be raised: ")
assert.True(t, result != nil, "Result should not be nil")
assert.True(t, result.WorkCount > 0, "Result.WorkCount should not be > 0")
assert.True(t, result.Works != nil, "Result.Works should not be nil")
printResult(result)
}
func TestSearchArtist(t *testing.T) {
Setup()
results, err := SearchArtist("Led Zeppelin", "GB")
if err != nil {
t.Log(err.Error())
t.Fail()
}
assert.True(t, err == nil, "Error should not be raised: ")
assert.True(t, results != nil, "Result should not be nil")
printResult(results)
}
func TestGetArtistWithValidMBID(t *testing.T) {
Setup()
result, err := GetArtist(artistMBID)
if err != nil {
t.Log(err.Error())
t.Fail()
}
assert.True(t, err == nil, "Error should not be raised: ")
assert.True(t, result != nil, "Result should not be nil")
assert.Equal(t, artistMBID, result.ID, "Expected recording MBID is different")
printResult(result)
}
func printResult(r ...interface{}) {
spew.Dump(r)
}
func Setup() {
SetMusicBrainzConfig("gomusicbrainz-test", "1.0", "[email protected]")
}