api tests: refactor weldr and jobqueue api tests to use common helpers
The helper functions in both api packages were more or less same. However, over time they have been slowly diverging. This commit extract the helpers into one common package to make the tests more maintainable and to deduplicate the code.
This commit is contained in:
parent
da311f13eb
commit
a00a0caa70
3 changed files with 198 additions and 248 deletions
|
|
@ -1,157 +1,22 @@
|
|||
package weldr_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
rpmmd_mock "github.com/osbuild/osbuild-composer/internal/mocks/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/store"
|
||||
"github.com/osbuild/osbuild-composer/internal/test"
|
||||
"github.com/osbuild/osbuild-composer/internal/weldr"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
_ "github.com/osbuild/osbuild-composer/internal/distro/test"
|
||||
)
|
||||
|
||||
func externalRequest(method, path, body string) *http.Response {
|
||||
client := http.Client{
|
||||
Transport: &http.Transport{
|
||||
DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
|
||||
return net.Dial("unix", "/run/weldr/api.socket")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(method, "http://localhost"+path, bytes.NewReader([]byte(body)))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if method == "POST" {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return resp
|
||||
}
|
||||
|
||||
func internalRequest(api *weldr.API, method, path, body string) *http.Response {
|
||||
req := httptest.NewRequest(method, path, bytes.NewReader([]byte(body)))
|
||||
|
||||
if method == "POST" {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
}
|
||||
resp := httptest.NewRecorder()
|
||||
api.ServeHTTP(resp, req)
|
||||
|
||||
return resp.Result()
|
||||
}
|
||||
|
||||
func sendHTTP(api *weldr.API, external bool, method, path, body string) *http.Response {
|
||||
if len(os.Getenv("OSBUILD_COMPOSER_TEST_EXTERNAL")) > 0 {
|
||||
if !external {
|
||||
return nil
|
||||
}
|
||||
return externalRequest(method, path, body)
|
||||
} else {
|
||||
return internalRequest(api, method, path, body)
|
||||
}
|
||||
}
|
||||
|
||||
// this function serves to drop fields that shouldn't be tested from the unmarshalled json objects
|
||||
func dropFields(obj interface{}, fields ...string) {
|
||||
switch v := obj.(type) {
|
||||
// if the interface type is a map attempt to delete the fields
|
||||
case map[string]interface{}:
|
||||
for i, field := range fields {
|
||||
if _, ok := v[field]; ok {
|
||||
delete(v, field)
|
||||
// if the field is found remove it from the fields slice
|
||||
if len(fields) < i-1 {
|
||||
fields = append(fields[:i], fields[i+1:]...)
|
||||
} else {
|
||||
fields = fields[:i]
|
||||
}
|
||||
}
|
||||
}
|
||||
// call dropFields on the remaining elements since they may contain a map containing the field
|
||||
for _, val := range v {
|
||||
dropFields(val, fields...)
|
||||
}
|
||||
// if the type is a list of interfaces call dropFields on each interface
|
||||
case []interface{}:
|
||||
for _, element := range v {
|
||||
dropFields(element, fields...)
|
||||
}
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func testRoute(t *testing.T, api *weldr.API, external bool, method, path, body string, expectedStatus int, expectedJSON string, ignoreFields ...string) {
|
||||
resp := sendHTTP(api, external, method, path, body)
|
||||
if resp == nil {
|
||||
t.Skip("This test is for internal testing only")
|
||||
}
|
||||
|
||||
if resp.StatusCode != expectedStatus {
|
||||
t.Errorf("%s: expected status %v, but got %v", path, expectedStatus, resp.StatusCode)
|
||||
}
|
||||
|
||||
replyJSON, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Errorf("%s: could not read response body: %v", path, err)
|
||||
return
|
||||
}
|
||||
|
||||
if expectedJSON == "" {
|
||||
if len(replyJSON) != 0 {
|
||||
t.Errorf("%s: expected no response body, but got:\n%s", path, replyJSON)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var reply, expected interface{}
|
||||
err = json.Unmarshal(replyJSON, &reply)
|
||||
if err != nil {
|
||||
t.Errorf("%s: %v\n%s", path, err, string(replyJSON))
|
||||
return
|
||||
}
|
||||
|
||||
if expectedJSON == "*" {
|
||||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(expectedJSON), &expected)
|
||||
if err != nil {
|
||||
t.Errorf("%s: expected JSON is invalid: %v", path, err)
|
||||
return
|
||||
}
|
||||
|
||||
dropFields(reply, ignoreFields...)
|
||||
dropFields(expected, ignoreFields...)
|
||||
|
||||
if !reflect.DeepEqual(reply, expected) {
|
||||
t.Errorf("%s: reply != expected:\n reply: %s\nexpected: %s", path, strings.TrimSpace(string(replyJSON)), expectedJSON)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func createWeldrAPI(fixture rpmmd_mock.Fixture) (*weldr.API, *store.Store) {
|
||||
s := store.New(nil)
|
||||
rpm := rpmmd_mock.NewRPMMDMock(fixture)
|
||||
|
|
@ -183,7 +48,7 @@ func TestBasic(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(rpmmd_mock.BaseFixture)
|
||||
testRoute(t, api, true, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.TestRoute(t, api, true, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +65,7 @@ func TestBlueprintsNew(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(rpmmd_mock.BaseFixture)
|
||||
testRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.TestRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -217,8 +82,8 @@ func TestBlueprintsWorkspace(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(rpmmd_mock.BaseFixture)
|
||||
sendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"test","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
testRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.SendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"test","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
test.TestRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -238,12 +103,12 @@ func TestBlueprintsInfo(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(rpmmd_mock.BaseFixture)
|
||||
sendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"test1","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
sendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"test2","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
sendHTTP(api, true, "POST", "/api/v0/blueprints/workspace", `{"name":"test2","description":"Test","packages":[{"name":"systemd","version":"123"}],"version":"0.0.0"}`)
|
||||
testRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
sendHTTP(api, true, "DELETE", "/api/v0/blueprints/delete/test2", ``)
|
||||
sendHTTP(api, true, "DELETE", "/api/v0/blueprints/delete/test1", ``)
|
||||
test.SendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"test1","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
test.SendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"test2","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
test.SendHTTP(api, true, "POST", "/api/v0/blueprints/workspace", `{"name":"test2","description":"Test","packages":[{"name":"systemd","version":"123"}],"version":"0.0.0"}`)
|
||||
test.TestRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.SendHTTP(api, true, "DELETE", "/api/v0/blueprints/delete/test2", ``)
|
||||
test.SendHTTP(api, true, "DELETE", "/api/v0/blueprints/delete/test1", ``)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -259,9 +124,9 @@ func TestBlueprintsFreeze(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(c.Fixture)
|
||||
sendHTTP(api, false, "POST", "/api/v0/blueprints/new", `{"name":"test","description":"Test","packages":[{"name":"dep-package1","version":"*"}],"version":"0.0.0"}`)
|
||||
testRoute(t, api, false, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
sendHTTP(api, false, "DELETE", "/api/v0/blueprints/delete/test", ``)
|
||||
test.SendHTTP(api, false, "POST", "/api/v0/blueprints/new", `{"name":"test","description":"Test","packages":[{"name":"dep-package1","version":"*"}],"version":"0.0.0"}`)
|
||||
test.TestRoute(t, api, false, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.SendHTTP(api, false, "DELETE", "/api/v0/blueprints/delete/test", ``)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -278,10 +143,10 @@ func TestBlueprintsDiff(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(rpmmd_mock.BaseFixture)
|
||||
sendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"test","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
sendHTTP(api, true, "POST", "/api/v0/blueprints/workspace", `{"name":"test","description":"Test","packages":[{"name":"systemd","version":"123"}],"version":"0.0.0"}`)
|
||||
testRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
sendHTTP(api, true, "DELETE", "/api/v0/blueprints/delete/test", ``)
|
||||
test.SendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"test","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
test.SendHTTP(api, true, "POST", "/api/v0/blueprints/workspace", `{"name":"test","description":"Test","packages":[{"name":"systemd","version":"123"}],"version":"0.0.0"}`)
|
||||
test.TestRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.SendHTTP(api, true, "DELETE", "/api/v0/blueprints/delete/test", ``)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -298,9 +163,9 @@ func TestBlueprintsDelete(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(rpmmd_mock.BaseFixture)
|
||||
sendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"test","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
testRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
sendHTTP(api, true, "DELETE", "/api/v0/blueprints/delete/test", ``)
|
||||
test.SendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"test","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
test.TestRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.SendHTTP(api, true, "DELETE", "/api/v0/blueprints/delete/test", ``)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -310,13 +175,13 @@ func TestBlueprintsChanges(t *testing.T) {
|
|||
id := strconv.Itoa(rand.Int())
|
||||
ignoreFields := []string{"commit", "timestamp"}
|
||||
|
||||
sendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"`+id+`","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
testRoute(t, api, true, "GET", "/api/v0/blueprints/changes/failing"+id, ``, http.StatusOK, `{"blueprints":[],"errors":[{"id":"UnknownBlueprint","msg":"failing`+id+`"}],"limit":20,"offset":0}`, ignoreFields...)
|
||||
testRoute(t, api, true, "GET", "/api/v0/blueprints/changes/"+id, ``, http.StatusOK, `{"blueprints":[{"changes":[{"commit":"","message":"Recipe `+id+`, version 0.0.0 saved.","revision":null,"timestamp":""}],"name":"`+id+`","total":1}],"errors":[],"limit":20,"offset":0}`, ignoreFields...)
|
||||
sendHTTP(api, true, "DELETE", "/api/v0/blueprints/delete/"+id, ``)
|
||||
sendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"`+id+`","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
testRoute(t, api, true, "GET", "/api/v0/blueprints/changes/"+id, ``, http.StatusOK, `{"blueprints":[{"changes":[{"commit":"","message":"Recipe `+id+`, version 0.0.0 saved.","revision":null,"timestamp":""},{"commit":"","message":"Recipe `+id+`, version 0.0.0 saved.","revision":null,"timestamp":""}],"name":"`+id+`","total":2}],"errors":[],"limit":20,"offset":0}`, ignoreFields...)
|
||||
sendHTTP(api, true, "DELETE", "/api/v0/blueprints/delete/"+id, ``)
|
||||
test.SendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"`+id+`","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
test.TestRoute(t, api, true, "GET", "/api/v0/blueprints/changes/failing"+id, ``, http.StatusOK, `{"blueprints":[],"errors":[{"id":"UnknownBlueprint","msg":"failing`+id+`"}],"limit":20,"offset":0}`, ignoreFields...)
|
||||
test.TestRoute(t, api, true, "GET", "/api/v0/blueprints/changes/"+id, ``, http.StatusOK, `{"blueprints":[{"changes":[{"commit":"","message":"Recipe `+id+`, version 0.0.0 saved.","revision":null,"timestamp":""}],"name":"`+id+`","total":1}],"errors":[],"limit":20,"offset":0}`, ignoreFields...)
|
||||
test.SendHTTP(api, true, "DELETE", "/api/v0/blueprints/delete/"+id, ``)
|
||||
test.SendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"`+id+`","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
test.TestRoute(t, api, true, "GET", "/api/v0/blueprints/changes/"+id, ``, http.StatusOK, `{"blueprints":[{"changes":[{"commit":"","message":"Recipe `+id+`, version 0.0.0 saved.","revision":null,"timestamp":""},{"commit":"","message":"Recipe `+id+`, version 0.0.0 saved.","revision":null,"timestamp":""}],"name":"`+id+`","total":2}],"errors":[],"limit":20,"offset":0}`, ignoreFields...)
|
||||
test.SendHTTP(api, true, "DELETE", "/api/v0/blueprints/delete/"+id, ``)
|
||||
}
|
||||
|
||||
func TestCompose(t *testing.T) {
|
||||
|
|
@ -335,9 +200,9 @@ func TestCompose(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(rpmmd_mock.BaseFixture)
|
||||
sendHTTP(api, c.External, "POST", "/api/v0/blueprints/new", `{"name":"test","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
testRoute(t, api, c.External, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON, c.IgnoreFields...)
|
||||
sendHTTP(api, c.External, "DELETE", "/api/v0/blueprints/delete/test", ``)
|
||||
test.SendHTTP(api, c.External, "POST", "/api/v0/blueprints/new", `{"name":"test","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
test.TestRoute(t, api, c.External, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON, c.IgnoreFields...)
|
||||
test.SendHTTP(api, c.External, "DELETE", "/api/v0/blueprints/delete/test", ``)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -359,23 +224,23 @@ func TestComposeQueue(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, s := createWeldrAPI(rpmmd_mock.BaseFixture)
|
||||
sendHTTP(api, false, "POST", "/api/v0/blueprints/new", `{"name":"test","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
test.SendHTTP(api, false, "POST", "/api/v0/blueprints/new", `{"name":"test","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.0"}`)
|
||||
// create job and leave it waiting
|
||||
sendHTTP(api, false, "POST", "/api/v0/compose", `{"blueprint_name": "test","compose_type": "tar","branch": "master"}`)
|
||||
test.SendHTTP(api, false, "POST", "/api/v0/compose", `{"blueprint_name": "test","compose_type": "tar","branch": "master"}`)
|
||||
// create job and leave it running
|
||||
sendHTTP(api, false, "POST", "/api/v0/compose", `{"blueprint_name": "test","compose_type": "tar","branch": "master"}`)
|
||||
test.SendHTTP(api, false, "POST", "/api/v0/compose", `{"blueprint_name": "test","compose_type": "tar","branch": "master"}`)
|
||||
s.PopCompose()
|
||||
// create job and mark it as finished
|
||||
sendHTTP(api, false, "POST", "/api/v0/compose", `{"blueprint_name": "test","compose_type": "tar","branch": "master"}`)
|
||||
test.SendHTTP(api, false, "POST", "/api/v0/compose", `{"blueprint_name": "test","compose_type": "tar","branch": "master"}`)
|
||||
job := s.PopCompose()
|
||||
s.UpdateCompose(job.ComposeID, "FINISHED")
|
||||
// create job and mark it as failed
|
||||
sendHTTP(api, false, "POST", "/api/v0/compose", `{"blueprint_name": "test","compose_type": "tar","branch": "master"}`)
|
||||
test.SendHTTP(api, false, "POST", "/api/v0/compose", `{"blueprint_name": "test","compose_type": "tar","branch": "master"}`)
|
||||
job = s.PopCompose()
|
||||
s.UpdateCompose(job.ComposeID, "FAILED")
|
||||
|
||||
testRoute(t, api, false, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON, c.IgnoreFields...)
|
||||
sendHTTP(api, false, "DELETE", "/api/v0/blueprints/delete/test", ``)
|
||||
test.TestRoute(t, api, false, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON, c.IgnoreFields...)
|
||||
test.SendHTTP(api, false, "DELETE", "/api/v0/blueprints/delete/test", ``)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -393,8 +258,8 @@ func TestSourcesNew(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(rpmmd_mock.BaseFixture)
|
||||
testRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
sendHTTP(api, true, "DELETE", "/api/v0/projects/source/delete/fish", ``)
|
||||
test.TestRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.SendHTTP(api, true, "DELETE", "/api/v0/projects/source/delete/fish", ``)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -412,9 +277,9 @@ func TestSourcesDelete(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(rpmmd_mock.BaseFixture)
|
||||
sendHTTP(api, true, "POST", "/api/v0/projects/source/new", `{"name": "fish","url": "https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/","type": "yum-baseurl","check_ssl": false,"check_gpg": false}`)
|
||||
testRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
sendHTTP(api, true, "DELETE", "/api/v0/projects/source/delete/fish", ``)
|
||||
test.SendHTTP(api, true, "POST", "/api/v0/projects/source/new", `{"name": "fish","url": "https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/","type": "yum-baseurl","check_ssl": false,"check_gpg": false}`)
|
||||
test.TestRoute(t, api, true, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.SendHTTP(api, true, "DELETE", "/api/v0/projects/source/delete/fish", ``)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -432,7 +297,7 @@ func TestProjectsDepsolve(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(c.Fixture)
|
||||
testRoute(t, api, true, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.TestRoute(t, api, true, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -453,7 +318,7 @@ func TestProjectsInfo(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(c.Fixture)
|
||||
testRoute(t, api, true, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.TestRoute(t, api, true, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -475,7 +340,7 @@ func TestModulesInfo(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(c.Fixture)
|
||||
testRoute(t, api, true, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.TestRoute(t, api, true, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -494,7 +359,7 @@ func TestProjectsList(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(c.Fixture)
|
||||
testRoute(t, api, true, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.TestRoute(t, api, true, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -516,6 +381,6 @@ func TestModulesList(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
api, _ := createWeldrAPI(c.Fixture)
|
||||
testRoute(t, api, true, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
test.TestRoute(t, api, true, "GET", c.Path, ``, c.ExpectedStatus, c.ExpectedJSON)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue