This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exam_test.go
96 lines (89 loc) · 2.56 KB
/
exam_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
package gokreta
import (
"fmt"
"testing"
)
func TestGetAllExams(t *testing.T) {
t.Run("low-level", TGetAllExams)
t.Run("high-level", TUserGetAllExams)
}
func TestGetAllExamsByDate(t *testing.T) {
t.Run("low-level", TGetAllExamsByDate)
t.Run("high-level", TUserGetAllExamsByDate)
}
func TGetAllExams(t *testing.T) {
instituteCode, userName, password, err := getCredetinalsFromFile()
authDetails, err := GetAuthDetailsByCredetinals(instituteCode, userName, password)
if err != nil {
fmt.Println(err)
t.Errorf("An error happened while trying to get all the exams!")
return
}
exams, err := GetAllExams(authDetails)
if err != nil || exams == nil {
fmt.Println(err)
t.Errorf("An error happened while trying to get all the exams!")
return
}
fmt.Println("TGetAllExams passed!")
fmt.Println("Result: ")
fmt.Println(exams)
fmt.Println()
}
func TGetAllExamsByDate(t *testing.T) {
instituteCode, userName, password, err := getCredetinalsFromFile()
authDetails, err := GetAuthDetailsByCredetinals(instituteCode, userName, password)
if err != nil {
fmt.Println(err)
t.Errorf("An error happened while trying to get all the exams by date!")
return
}
exams, err := GetAllExamsByDate(authDetails, "null", "null")
if err != nil || exams == nil {
fmt.Println(err)
t.Errorf("An error happened while trying to get all the exams by date!")
return
}
fmt.Println("TGetAllExamsByDate passed!")
fmt.Println("Result: ")
fmt.Println(exams)
fmt.Println()
}
func TUserGetAllExams(t *testing.T) {
instituteCode, userName, password, err := getCredetinalsFromFile()
user, err := NewUser(instituteCode, userName, password)
if err != nil {
fmt.Println(err)
t.Errorf("An error happened while trying to get all the exams (from User)!")
return
}
exams, err := user.GetAllExams()
if err != nil {
fmt.Println(err)
t.Errorf("An error happened while trying to get all the exams (from User)!")
return
}
fmt.Println("TUserGetAllExams passed!")
fmt.Println("Result: ")
fmt.Println(exams)
fmt.Println()
}
func TUserGetAllExamsByDate(t *testing.T) {
instituteCode, userName, password, err := getCredetinalsFromFile()
user, err := NewUser(instituteCode, userName, password)
if err != nil {
fmt.Println(err)
t.Errorf("An error happened while trying to get all the exams by date (from User)!")
return
}
exams, err := user.GetAllExams()
if err != nil {
fmt.Println(err)
t.Errorf("An error happened while trying to get all the exams by date(from User)!")
return
}
fmt.Println("TUserGetAllExamsByDate passed!")
fmt.Println("Result: ")
fmt.Println(exams)
fmt.Println()
}