-
Notifications
You must be signed in to change notification settings - Fork 0
/
checker_test.go
31 lines (28 loc) · 1.47 KB
/
checker_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
package gotten
import (
"github.com/Hexilee/gotten/headers"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)
var (
TestResponse = &http.Response{
StatusCode: http.StatusOK,
Header: map[string][]string{
headers.HeaderContentType: {"text/html"},
},
}
)
func TestCheckerFactory_Create(t *testing.T) {
assert.True(t, new(CheckerFactory).Create().Check(TestResponse))
assert.True(t, new(CheckerFactory).WhenStatuses(http.StatusOK).Create().Check(TestResponse))
assert.True(t, new(CheckerFactory).WhenStatuses(http.StatusOK, http.StatusAccepted).Create().Check(TestResponse))
assert.True(t, new(CheckerFactory).WhenContentType("text/html").Create().Check(TestResponse))
assert.True(t, new(CheckerFactory).WhenContentType("text/html", "text/xml").Create().Check(TestResponse))
assert.True(t, new(CheckerFactory).WhenStatuses(http.StatusOK).WhenContentType("text/html").Create().Check(TestResponse))
assert.False(t, new(CheckerFactory).WhenStatuses(http.StatusAccepted).Create().Check(TestResponse))
assert.False(t, new(CheckerFactory).WhenContentType("text/xml").Create().Check(TestResponse))
assert.False(t, new(CheckerFactory).WhenStatuses(http.StatusAccepted).WhenContentType("text/html").Create().Check(TestResponse))
assert.False(t, new(CheckerFactory).WhenStatuses(http.StatusOK).WhenContentType("text/xml").Create().Check(TestResponse))
assert.False(t, new(CheckerFactory).WhenStatuses(http.StatusAccepted).WhenContentType("text/xml").Create().Check(TestResponse))
}