Skip to content

Commit

Permalink
cloudapi: add upload targets to route handler tests
Browse files Browse the repository at this point in the history
  • Loading branch information
achilleas-k committed Oct 30, 2023
1 parent ac2bf04 commit 68f48b0
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions internal/cloudapi/v2/v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ func TestCompose(t *testing.T) {
// "reason": "Requested method isn't supported for resource"
// }`, "operation_id")

// With upload options for default target
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
{
"distribution": "%s",
Expand All @@ -310,6 +311,59 @@ func TestCompose(t *testing.T) {
"href": "/api/image-builder-composer/v2/compose",
"kind": "ComposeId"
}`, "id")

// With upload options for specific upload target
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
{
"distribution": "%s",
"image_request":{
"architecture": "%s",
"image_type": "aws",
"repositories": [{
"baseurl": "somerepo.org",
"rhsm": false
}],
"upload_targets": [{
"type": "aws",
"upload_options": {
"region": "eu-central-1"
}
}]
}
}`, test_distro.TestDistroName, test_distro.TestArch3Name), http.StatusCreated, `
{
"href": "/api/image-builder-composer/v2/compose",
"kind": "ComposeId"
}`, "id")

// With both upload options for default target and a specific target
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
{
"distribution": "%s",
"image_request":{
"architecture": "%s",
"image_type": "aws",
"repositories": [{
"baseurl": "somerepo.org",
"rhsm": false
}],
"upload_targets": [{
"type": "aws",
"upload_options": {
"region": "eu-central-1"
}
}],
"upload_options": {
"region": "eu-central-1"
}
}
}`, test_distro.TestDistroName, test_distro.TestArch3Name), http.StatusCreated, `
{
"href": "/api/image-builder-composer/v2/compose",
"kind": "ComposeId"
}`, "id")

// Koji
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
{
"distribution": "%s",
Expand Down Expand Up @@ -360,6 +414,36 @@ func TestCompose(t *testing.T) {
"kind": "ComposeId"
}`, "id")

// ref only with secondary pulp upload target
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
{
"distribution": "%s",
"image_request":{
"architecture": "%s",
"image_type": "edge-commit",
"repositories": [{
"baseurl": "somerepo.org",
"rhsm": false
}],
"upload_targets": [{
"type": "pulp.ostree",
"upload_options": {
"basepath": "edge/rhel10"
}
}],
"upload_options": {
"region": "eu-central-1"
},
"ostree": {
"ref": "rhel/10/x86_64/edge"
}
}
}`, test_distro.TestDistroName, test_distro.TestArch3Name), http.StatusCreated, `
{
"href": "/api/image-builder-composer/v2/compose",
"kind": "ComposeId"
}`, "id")

// url only (must use ostreeRepoDefault for default ref)
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
{
Expand Down

0 comments on commit 68f48b0

Please sign in to comment.