weldr/test: split out sendHTTP helper method
This simplifies the code a bit, and will be used in follow-up patches to distinguish between setup calls and explicit tests. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
f055ba2e07
commit
8c3cd245d8
1 changed files with 11 additions and 6 deletions
|
|
@ -67,16 +67,21 @@ func internalRequest(api *weldr.API, method, path, body string) *http.Response {
|
|||
return resp.Result()
|
||||
}
|
||||
|
||||
func testRoute(t *testing.T, api *weldr.API, external bool, method, path, body string, expectedStatus int, expectedJSON string) {
|
||||
var resp *http.Response
|
||||
|
||||
func sendHTTP(api *weldr.API, external bool, method, path, body string) *http.Response {
|
||||
if len(os.Getenv("OSBUILD_COMPOSER_TEST_EXTERNAL")) > 0 {
|
||||
if !external {
|
||||
t.Skip("This test is for internal testing only")
|
||||
return nil
|
||||
}
|
||||
resp = externalRequest(method, path, body)
|
||||
return externalRequest(method, path, body)
|
||||
} else {
|
||||
resp = internalRequest(api, method, path, body)
|
||||
return internalRequest(api, method, path, body)
|
||||
}
|
||||
}
|
||||
|
||||
func testRoute(t *testing.T, api *weldr.API, external bool, method, path, body string, expectedStatus int, expectedJSON string) {
|
||||
resp := sendHTTP(api, external, method, path, body)
|
||||
if resp == nil {
|
||||
t.Skip("This test is for internal testing only")
|
||||
}
|
||||
|
||||
if resp.StatusCode != expectedStatus {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue