mirror of
https://gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud
synced 2024-11-06 10:26:24 +00:00
27 lines
567 B
Go
27 lines
567 B
Go
package grequests
|
|
|
|
import (
|
|
"strconv"
|
|
"testing"
|
|
)
|
|
|
|
func TestResponseOk(t *testing.T) {
|
|
status := []int{200, 201, 202, 203, 204, 205, 206, 207, 208, 226}
|
|
for _, status := range status {
|
|
verifyResponseOkForStatus(status, t)
|
|
}
|
|
}
|
|
|
|
func verifyResponseOkForStatus(status int, t *testing.T) {
|
|
url := "http://httpbin.org/status/" + strconv.Itoa(status)
|
|
resp, err := Get(url, nil)
|
|
|
|
if err != nil {
|
|
t.Error("Unable to make request", err)
|
|
}
|
|
|
|
if resp.Ok != true {
|
|
t.Errorf("Request did not return OK. Received status code %d rather a 2xx.", resp.StatusCode)
|
|
}
|
|
}
|