mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
Modifies NewTestEndpoint() by removing if body == nil
This commit is contained in:
parent
94ea3c4ebf
commit
ff19fdcdaf
1 changed files with 7 additions and 15 deletions
|
@ -97,7 +97,7 @@ func NewTestEndpoint(router *gin.Engine, token string, url string,
|
||||||
return fmt.Errorf("Failed to marshal reqeust body: %v", err)
|
return fmt.Errorf("Failed to marshal reqeust body: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if body != nil {
|
// Create the request
|
||||||
req, err := http.NewRequest(method, url, bytes.NewBuffer(body))
|
req, err := http.NewRequest(method, url, bytes.NewBuffer(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to create new request: %v", err)
|
return fmt.Errorf("Failed to create new request: %v", err)
|
||||||
|
@ -105,14 +105,6 @@ func NewTestEndpoint(router *gin.Engine, token string, url string,
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
req.Header.Add("Authorization", "Bearer "+token)
|
req.Header.Add("Authorization", "Bearer "+token)
|
||||||
router.ServeHTTP(w, req)
|
router.ServeHTTP(w, req)
|
||||||
} else {
|
|
||||||
req, err := http.NewRequest(method, url, nil)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Failed to create new request: %v", err)
|
|
||||||
}
|
|
||||||
req.Header.Add("Authorization", "Bearer "+token)
|
|
||||||
router.ServeHTTP(w, req)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the return HTTP Code
|
// Check the return HTTP Code
|
||||||
if w.Code != expected_code {
|
if w.Code != expected_code {
|
||||||
|
|
Loading…
Add table
Reference in a new issue