-
Notifications
You must be signed in to change notification settings - Fork 1
/
structs_test.go
53 lines (39 loc) 路 891 Bytes
/
structs_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 library
import (
"log"
"testing"
)
func TestEventStrcuts(t *testing.T) {
urlEvents := "https://eonet.gsfc.nasa.gov/api/v3/events"
event := new(EventResponse)
err := getJson(urlEvents, event)
if err != nil {
log.Fatal(err)
}
want := event.Events[0].Title
for index, value := range event.Events {
if index == 0 {
got := value.Title
if got != want {
t.Errorf("got %v want %v", got, want)
}
}
}
}
func TestCategoriestrcuts(t *testing.T) {
urlCategories := "https://eonet.gsfc.nasa.gov/api/v3/categories/"
CategoriesRes := new(CategoriesResponse)
err := getJson(urlCategories, CategoriesRes)
if err != nil {
log.Fatal(err)
}
want := CategoriesRes.Categories[0].Title
for index, value := range CategoriesRes.Categories {
if index == 0 {
got := value.Title
if got != want {
t.Errorf("got %v want %v", got, want)
}
}
}
}