improve body contains check
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -25,7 +25,7 @@ func RunTest(testCase *TestCase) error {
|
||||
}
|
||||
client := &http.Client{Transport: tr}
|
||||
|
||||
fmt.Printf("Running test '%s'\n", testCase.Name)
|
||||
fmt.Printf("\nRunning %s : %s\n", testCase.Name, testCase.Description)
|
||||
|
||||
// Determine URL
|
||||
if len(testDefinitions.BaseUrl) > 0 {
|
||||
@@ -50,8 +50,11 @@ func RunTest(testCase *TestCase) error {
|
||||
requestType = testCase.Method
|
||||
}
|
||||
|
||||
fmt.Printf("Preparing %s for endpoint %s\n", requestType, requestUrl)
|
||||
|
||||
// Create request
|
||||
if len(testCase.Body) > 0 {
|
||||
fmt.Printf("Adding body to request : %s\n", testCase.Body)
|
||||
req, err = http.NewRequest(requestType, requestUrl, bytes.NewBuffer(testCase.Body))
|
||||
} else {
|
||||
req, err = http.NewRequest(requestType, requestUrl, nil)
|
||||
@@ -87,6 +90,7 @@ func RunTest(testCase *TestCase) error {
|
||||
}
|
||||
|
||||
// Perform request
|
||||
fmt.Printf("Sending request\n")
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
@@ -98,7 +102,7 @@ func RunTest(testCase *TestCase) error {
|
||||
testCase.ResultStatusCode = resp.StatusCode
|
||||
testCase.ResultHeaders = resp.Header
|
||||
|
||||
fmt.Printf("http_status:\n'%+v'\n", testCase.ResultStatusCode)
|
||||
fmt.Printf("Status Code: %s\n", resp.Status)
|
||||
fmt.Printf("Header response:\n%+v\n", testCase.ResultHeaders)
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
|
Reference in New Issue
Block a user