-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcourse_module_test.go
54 lines (46 loc) · 1.1 KB
/
course_module_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
package moodle
import (
"fmt"
"testing"
)
func TestCourseModule(t *testing.T) {
api := NewMoodleApi(requireEnv("MOODLE_URL", t), requireEnv("MOODLE_KEY", t))
s, err := api.GetCourses(" LIBRARY")
if err != nil {
t.Errorf("GetCourses() failed: %v", err)
}
if s == nil {
t.Errorf("GetCourses() should return items")
}
if len(s) < 1 {
t.Errorf("Expecting search results")
}
roles, err := api.GetCourseRoles(s[0].MoodleId)
if err != nil {
t.Errorf("GetCourseRoles() failed: %v", err)
}
if roles == nil {
t.Errorf("GetCourseRoles() should return results")
}
if len(roles) < 1 {
t.Errorf("Expecting search results")
}
fmt.Printf("roles: %d\n", len(roles))
r, _ := api.GetCourseRoles(36)
if r == nil {
t.Errorf("Course does not exist")
}
if len(r) < 1 {
t.Errorf("No roles in course")
}
cm, err := api.GetCourseModule(1155)
if err != nil {
t.Errorf("Module fetch failed: %v", err)
}
if cm == nil {
t.Errorf("Module does not exist")
//t.Errorf("Sum was incorrect, got: %d, want: %d.", total, 10)
}
fmt.Printf("Found availability %v\n", cm.Availability)
//t.Errorf("%v", cm)
}