-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprocessor_test.go
45 lines (37 loc) · 1.11 KB
/
processor_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
package main
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
type httpClientMock struct{}
func (mock httpClientMock) execute(_, _ string, _ XTestSuiteRequest) (statusCode int, body []byte, err error) {
return 200, []byte(`{ "status": "ok" }`), nil
}
func TestProcessGetTestSuite(t *testing.T) {
xTestSuite := XTestSuite{
Description: "[POS] Should return success",
Request: XTestSuiteRequest{
QueryParam: map[string]string{
"date": "2022-01-01",
},
Header: map[string]string{
"X-Business-ID": "mock-biz-id",
},
PathParam: map[string]string{
"id": "1",
},
},
Response: XTestSuiteResponse{
HTTPStatus: http.StatusOK,
Body: `{ "status": "ok" }`,
},
}
xTestSuites := []XTestSuite{xTestSuite}
testProcessor := newTestProcessor(httpClientMock{})
testSuites := testProcessor.processTestSuites("GET", "/users", xTestSuites)
assert.Equal(t, "[POS] Should return success", testSuites[0].Description)
assert.Equal(t, "GET", testSuites[0].Operation)
assert.Equal(t, testResultPassed, testSuites[0].Status)
assert.Equal(t, "/users", testSuites[0].PathName)
}