-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlesson_test.go
41 lines (28 loc) · 981 Bytes
/
lesson_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
package main
import (
"testing"
"github.com/anton2920/gofa/net/http"
)
func TestLessonPageHandler(t *testing.T) {
const endpoint = "/lesson/"
testCreateInitialDBs()
expectedOK := [...]string{"0", "1", "2"}
expectedBadRequest := [...]string{"a", "b", "c"}
expectedForbidden := expectedOK[:2]
expectedNotFound := [...]string{"3", "4", "5"}
for _, id := range expectedOK {
testGetAuth(t, endpoint+id, testTokens[AdminID], http.StatusOK)
}
testGetAuth(t, endpoint+"2", testTokens[2], http.StatusOK)
for _, id := range expectedBadRequest {
testGetAuth(t, endpoint+id, testTokens[AdminID], http.StatusBadRequest)
}
testGet(t, endpoint, http.StatusUnauthorized)
testGetAuth(t, endpoint, testInvalidToken, http.StatusUnauthorized)
for _, id := range expectedForbidden {
testGetAuth(t, endpoint+id, testTokens[3], http.StatusForbidden)
}
for _, id := range expectedNotFound {
testGetAuth(t, endpoint+id, testTokens[AdminID], http.StatusNotFound)
}
}