The API is always advertising a content type of application/json, but
not sending JSON on errors.
Change it to send simple JSON objects like this:
{ "message": "something went wrong" }
This can be extended to include more structured information in the
future.
Also return an (for now) empty JSON object from `addJobHandler()`. It
returned nothing before, which is invalid JSON.
Stop testing for the actual error strings in `api_test.go`. These are
meant for humans and can change. Only check what a client could
meaningfully check for, which is only the HTTP status code right now.
31 lines
719 B
Go
31 lines
719 B
Go
package jobqueue
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/osbuild/osbuild-composer/internal/common"
|
|
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
|
"github.com/osbuild/osbuild-composer/internal/target"
|
|
)
|
|
|
|
type errorResponse struct {
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
type addJobRequest struct {
|
|
}
|
|
|
|
type addJobResponse struct {
|
|
ComposeID uuid.UUID `json:"compose_id"`
|
|
ImageBuildID int `json:"image_build_id"`
|
|
Manifest *osbuild.Manifest `json:"manifest"`
|
|
Targets []*target.Target `json:"targets"`
|
|
}
|
|
|
|
type updateJobRequest struct {
|
|
Status common.ImageBuildState `json:"status"`
|
|
Result *common.ComposeResult `json:"result"`
|
|
}
|
|
|
|
type updateJobResponse struct {
|
|
}
|