-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
config_test.go
207 lines (189 loc) · 5.05 KB
/
config_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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
package bsvrates
import (
"testing"
"github.com/stretchr/testify/assert"
)
// TestProvider_IsValid will test the method IsValid()
func TestProvider_IsValid(t *testing.T) {
t.Parallel()
var tests = []struct {
testCase string
provider Provider
expectedValid bool
}{
{"provider 0", 0, false},
{"provider 1", 1, true},
{"provider 2", 2, true},
{"provider 3", 3, false},
{"ProviderWhatsOnChain", ProviderWhatsOnChain, true},
{"ProviderCoinPaprika", ProviderCoinPaprika, true},
{"providerLast", providerLast, false},
}
for _, test := range tests {
t.Run(test.testCase, func(t *testing.T) {
isValid := test.provider.IsValid()
assert.Equal(t, test.expectedValid, isValid)
})
}
}
// TestProvider_Name will test the method Name()
func TestProvider_Name(t *testing.T) {
t.Parallel()
var tests = []struct {
testCase string
provider Provider
expectedName string
}{
{"provider 0", 0, ""},
{"provider 1", 1, "WhatsOnChain"},
{"provider 2", 2, "CoinPaprika"},
{"provider 4", 3, ""},
{"ProviderWhatsOnChain", ProviderWhatsOnChain, "WhatsOnChain"},
{"ProviderCoinPaprika", ProviderCoinPaprika, "CoinPaprika"},
{"providerLast", providerLast, ""},
}
for _, test := range tests {
t.Run(test.testCase, func(t *testing.T) {
name := test.provider.Name()
assert.Equal(t, test.expectedName, name)
})
}
}
// TestProviderToName will test the method ProviderToName()
func TestProviderToName(t *testing.T) {
t.Parallel()
var tests = []struct {
testCase string
provider Provider
expectedName string
}{
{"provider 0", 0, ""},
{"provider 1", 1, "WhatsOnChain"},
{"provider 2", 2, "CoinPaprika"},
{"provider 4", 3, ""},
{"ProviderWhatsOnChain", ProviderWhatsOnChain, "WhatsOnChain"},
{"ProviderCoinPaprika", ProviderCoinPaprika, "CoinPaprika"},
{"providerLast", providerLast, ""},
}
for _, test := range tests {
t.Run(test.testCase, func(t *testing.T) {
name := ProviderToName(test.provider)
assert.Equal(t, test.expectedName, name)
})
}
}
// TestCurrency_IsValid will test the method IsValid()
func TestCurrency_IsValid(t *testing.T) {
t.Parallel()
// Create the list of tests
var tests = []struct {
testCase string
currency Currency
expectedValid bool
}{
{"currency 0", 0, false},
{"currency 1", 1, true},
{"currency 2", 2, true},
{"currency 3", 3, false},
{"CurrencyDollars", CurrencyDollars, true},
{"CurrencyBitcoin", CurrencyBitcoin, true},
{"currencyLast", currencyLast, false},
}
for _, test := range tests {
t.Run(test.testCase, func(t *testing.T) {
isValid := test.currency.IsValid()
assert.Equal(t, test.expectedValid, isValid)
})
}
}
// TestCurrency_Name will test the method Name()
func TestCurrency_Name(t *testing.T) {
t.Parallel()
// Create the list of tests
var tests = []struct {
testCase string
currency Currency
expectedName string
}{
{"currency 0", 0, ""},
{"currency 1", 1, usd},
{"currency 2", 2, "bsv"},
{"currency 3", 3, ""},
{"CurrencyDollars", CurrencyDollars, usd},
{"CurrencyBitcoin", CurrencyBitcoin, "bsv"},
{"currencyLast", currencyLast, ""},
}
for _, test := range tests {
t.Run(test.testCase, func(t *testing.T) {
name := test.currency.Name()
assert.Equal(t, test.expectedName, name)
})
}
}
// TestCurrencyToName will test the method CurrencyToName()
func TestCurrencyToName(t *testing.T) {
t.Parallel()
// Create the list of tests
var tests = []struct {
testCase string
currency Currency
expectedName string
}{
{"currency 0", 0, ""},
{"currency 1", 1, usd},
{"currency 2", 2, "bsv"},
{"currency 3", 3, ""},
{"CurrencyDollars", CurrencyDollars, usd},
{"CurrencyBitcoin", CurrencyBitcoin, "bsv"},
{"currencyLast", currencyLast, ""},
}
for _, test := range tests {
t.Run(test.testCase, func(t *testing.T) {
name := CurrencyToName(test.currency)
assert.Equal(t, test.expectedName, name)
})
}
}
// TestCurrencyFromName will test the method CurrencyFromName()
func TestCurrencyFromName(t *testing.T) {
t.Parallel()
var tests = []struct {
testCase string
currency string
expectedCurrency Currency
}{
{"", "", CurrencyDollars},
{usd, usd, CurrencyDollars},
{"bsv", "bsv", CurrencyBitcoin},
{"bogus", "bogus", CurrencyDollars},
}
for _, test := range tests {
t.Run(test.testCase, func(t *testing.T) {
currency := CurrencyFromName(test.currency)
assert.Equal(t, test.expectedCurrency, currency)
})
}
}
// TestCurrency_IsAccepted will test the method IsAccepted()
func TestCurrency_IsAccepted(t *testing.T) {
t.Parallel()
var tests = []struct {
testCase string
currency Currency
expectedValid bool
}{
{"currency 0", 0, false},
{"currency 1", 1, true},
{"currency 2", 2, false},
{"currency 3", 3, false},
{"CurrencyDollars", CurrencyDollars, true},
{"CurrencyBitcoin", CurrencyBitcoin, false},
{"currencyLast", currencyLast, false},
}
for _, test := range tests {
t.Run(test.testCase, func(t *testing.T) {
isValid := test.currency.IsAccepted()
assert.Equal(t, test.expectedValid, isValid)
})
}
}