-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathserver_test.go
More file actions
41 lines (34 loc) · 752 Bytes
/
server_test.go
File metadata and controls
41 lines (34 loc) · 752 Bytes
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 admin
import (
"io"
"net/http"
"os"
"testing"
"time"
"github.com/snowlyg/iris-admin/conf"
)
func TestStart(t *testing.T) {
go func() {
os.Setenv("IRIS_ADMIN_WEB_ADDR", "127.0.0.1:18088")
c := conf.NewConf()
if serve, err := NewServe(c); err != nil {
t.Error(err.Error())
} else {
serve.Engine()
serve.Run()
}
}()
time.Sleep(3 * time.Second)
resp, err := http.Get("http://127.0.0.1:18088")
if err != nil {
t.Errorf("test web start get %v", err)
}
defer resp.Body.Close()
_, err = io.ReadAll(resp.Body)
if err != nil {
t.Errorf("test web start get %v", err)
}
if resp.StatusCode != http.StatusNotFound {
t.Errorf("test web start want [%d] but get [%d]", http.StatusNotFound, resp.StatusCode)
}
}