-
Notifications
You must be signed in to change notification settings - Fork 3
/
httpcheck_test.go
46 lines (43 loc) · 1.12 KB
/
httpcheck_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
package gofofa
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestCheckActive(t *testing.T) {
tests := []struct {
name string
fixedHostInfo string
want HttpResponse
}{
{
name: "Success base",
fixedHostInfo: "http://www.baidu.com",
want: HttpResponse{IsActive: true, StatusCode: "200"},
},
{
name: "Fail base",
fixedHostInfo: "http://www.sadhdkashdaskjdhsajkhkjhdaskhd.com",
want: HttpResponse{IsActive: false, StatusCode: "0"},
},
{
name: "IP base",
fixedHostInfo: "123.58.224.8",
want: HttpResponse{IsActive: true, StatusCode: "200"},
},
{
name: "Domain base",
fixedHostInfo: "baidu.com",
want: HttpResponse{IsActive: true, StatusCode: "200"},
},
{
name: "HTTPS base",
fixedHostInfo: "https://fofa.info",
want: HttpResponse{IsActive: true, StatusCode: "200"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equalf(t, tt.want, DoHttpCheck(tt.fixedHostInfo, 3), "CheckActive(%v)", tt.fixedHostInfo)
})
}
}