cloudapi: Add a test for metadata returning the compose request
Related: RHEL-60120
This commit is contained in:
parent
d8e9a86921
commit
5e3d6aff54
1 changed files with 56 additions and 0 deletions
|
|
@ -2068,3 +2068,59 @@ func TestDownloadUnknown(t *testing.T) {
|
|||
"reason":"Compose with given id not found"
|
||||
}`, "operation_id")
|
||||
}
|
||||
|
||||
// TestComposeRequestMetadata tests that the original ComposeRequest is included with the
|
||||
// metadata response.
|
||||
func TestComposeRequestMetadata(t *testing.T) {
|
||||
srv, wrksrv, _, cancel := newV2Server(t, t.TempDir(), false, false)
|
||||
defer cancel()
|
||||
|
||||
request := fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "%s",
|
||||
"image_requests":[{
|
||||
"architecture": "%s",
|
||||
"image_type": "aws",
|
||||
"repositories": [{
|
||||
"baseurl": "somerepo.org",
|
||||
"rhsm": false
|
||||
}],
|
||||
"upload_options": {
|
||||
"region": "eu-central-1"
|
||||
}
|
||||
}]
|
||||
}`, test_distro.TestDistro1Name, test_distro.TestArch3Name)
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", request, http.StatusCreated, `
|
||||
{
|
||||
"href": "/api/image-builder-composer/v2/compose",
|
||||
"kind": "ComposeId"
|
||||
}`, "id")
|
||||
|
||||
jobId, _, jobType, args, dynArgs, err := wrksrv.RequestJob(context.Background(), test_distro.TestArch3Name, []string{worker.JobTypeOSBuild}, []string{""}, uuid.Nil)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, worker.JobTypeOSBuild, jobType)
|
||||
|
||||
var osbuildJob worker.OSBuildJob
|
||||
err = json.Unmarshal(args, &osbuildJob)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 0, len(osbuildJob.Manifest))
|
||||
require.NotEqual(t, 0, len(dynArgs[0]))
|
||||
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/composes/%v", jobId), ``, http.StatusOK, fmt.Sprintf(`
|
||||
{
|
||||
"href": "/api/image-builder-composer/v2/composes/%v",
|
||||
"kind": "ComposeStatus",
|
||||
"id": "%v",
|
||||
"image_status": {"status": "building"},
|
||||
"status": "pending"
|
||||
}`, jobId, jobId))
|
||||
|
||||
// metadata response should include the ComposeRequest even when build is not done
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/composes/%v/metadata", jobId), ``, http.StatusOK,
|
||||
fmt.Sprintf(`{
|
||||
"href": "/api/image-builder-composer/v2/composes/%[1]v/metadata",
|
||||
"id": "%[1]v",
|
||||
"kind": "ComposeMetadata",
|
||||
"request": %s
|
||||
}`, jobId, request))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue