-
Notifications
You must be signed in to change notification settings - Fork 0
/
meteocat_test.go
53 lines (45 loc) · 1.19 KB
/
meteocat_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
package meteocat
import (
"testing"
)
// TestValidDataUnit tests whether or not ValidDataUnit provides
// the correct assertion on provided data unit.
func TestValidCodisEstacions(t *testing.T) {
for u := range CodisEstacions {
if !ValidCodiEstacio(u) {
t.Error("False positive on data unit")
}
}
if ValidCodiEstacio("anything") {
t.Error("Invalid data unit")
}
}
// TestValidCodiVariable tests whether or not ValidCodiVariable provides
// the correct assertion on provided data unit.
func TestValidCodiVariable(t *testing.T) {
for _, s := range CodisVariables {
if !ValidCodiVariable(s) {
t.Error("False positive on data unit symbol")
}
}
if ValidCodiVariable("X") {
t.Error("Invalid data unit symbol")
}
}
// TestCheckAPIKeyExists tests whether or not CheckAPIKeyExists provides
// the correct assertion on provided data unit.
func TestCheckAPIKeyExists(t *testing.T) {
apiKey := "asdf1234"
if !CheckAPIKeyExists(apiKey) {
t.Error("Key not set")
}
}
// TestSetOptionsWithEmpty tests setOptions function will do nothing
// when options are empty.
func TestSetOptionsWithEmpty(t *testing.T) {
s := NewSettings()
err := setOptions(s, nil)
if err != nil {
t.Error(err)
}
}