forked from svicknesh/myschoollist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_test.go
81 lines (65 loc) · 1.91 KB
/
list_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
package myschoollist
import (
"log"
"testing"
)
func TestList(t *testing.T) {
list, err := New()
if nil != err {
log.Panic(err)
}
//PrintStructure(list.StatesGetAll())
// get some state information
stateID := 7
log.Printf("Get state information by ID %d", stateID)
state, found := list.StateGetByID(stateID)
if !found {
log.Printf("State ID %d not found", stateID)
}
PrintStructure(state)
stateShortname := "png"
log.Printf("Get state information by shortname %q", stateShortname)
state, found = list.StateGetByShortname(stateShortname)
if !found {
log.Printf("State shortname %q not found", stateShortname)
}
PrintStructure(state)
log.Printf("Get districts in state ID %d", stateID)
districts := list.StateGetDistricts(stateID)
PrintStructure(districts)
// --- end state ---
// get some district information
districtID := 73
log.Printf("Get district information by ID %d", districtID)
district, found := list.DistrictGetByID(districtID)
if !found {
log.Printf("District ID %d not found", districtID)
}
PrintStructure(district)
log.Printf("Get state information by district ID %d", districtID)
state, found = list.DistrictGetState(districtID)
if !found {
log.Printf("District ID %d not found", districtID)
}
PrintStructure(state)
log.Printf("Get schools information in district ID %d", districtID)
schools := list.DistrictGetSchools(districtID)
PrintStructure(schools)
// --- end district ---
// get some school information
schoolID := 9429
log.Printf("Get school information by ID %d", schoolID)
school, found := list.SchoolGetByID(schoolID)
if !found {
log.Printf("School ID %d not found", schoolID)
}
PrintStructure(school)
schoolCode := "peb1094"
log.Printf("Get school information by code %q", schoolCode)
school, found = list.SchoolGetByCode(schoolCode)
if !found {
log.Printf("School code %q not found", schoolCode)
}
PrintStructure(school)
// --- end school ---
}