forked from GoAdminGroup/go-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
46 lines (38 loc) · 1.39 KB
/
api.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
package common
import (
"fmt"
"net/http"
"github.com/dikiharyadi19/go-admin/modules/config"
"github.com/dikiharyadi19/go-admin/plugins/admin/modules/constant"
"github.com/gavv/httpexpect"
)
func apiTest(e *httpexpect.Expect, sesID *http.Cookie) {
fmt.Println()
printlnWithColor("Api", "blue")
fmt.Println("============================")
printlnWithColor("show", "green")
e.GET(config.Url("/api/list/manager")).
WithHeader("Accept", "application/json, text/plain, */*").
WithCookie(sesID.Name, sesID.Value).
Expect().
Status(200).JSON().Object().ValueEqual("code", 200)
//printlnWithColor("update form without id", "green")
//e.GET(config.Url("/api/edit/form/manager")).
// WithHeader("Accept", "application/json, text/plain, */*").
// WithCookie(sesID.Name, sesID.Value).
// Expect().
// Status(400).JSON().Object().ValueEqual("code", 400)
printlnWithColor("update form", "green")
e.GET(config.Url("/api/edit/form/manager")).
WithHeader("Accept", "application/json, text/plain, */*").
WithQuery(constant.EditPKKey, "1").
WithCookie(sesID.Name, sesID.Value).
Expect().
Status(200).JSON().Object().ValueEqual("code", 200)
printlnWithColor("create form", "green")
e.GET(config.Url("/api/create/form/manager")).
WithHeader("Accept", "application/json, text/plain, */*").
WithCookie(sesID.Name, sesID.Value).
Expect().
Status(200).JSON().Object().ValueEqual("code", 200)
}