weldr/tests: add first version of a compose/queue test
This can serve as a starting point, but it shows there are a few problems to solve: we need to verify json that depends on the setup, in particular, the json the queue contains will contain UUID's that are generated out of our control. Moreover, the setup for this test only makes sense for internal test, so I think we may want to change the logic for whether or not a test sholud be supported to be run externally to be per test-function, rather than per call to sendHTTP(). Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
26995d7a1d
commit
fd33ea1cc7
1 changed files with 37 additions and 0 deletions
|
|
@ -285,3 +285,40 @@ func TestCompose(t *testing.T) {
|
|||
sendHTTP(api, c.External, "DELETE", "/api/v0/blueprints/delete/test", ``)
|
||||
}
|
||||
}
|
||||
|
||||
func TestComposeQueue(t *testing.T) {
|
||||
var cases = []struct {
|
||||
Method string
|
||||
Path string
|
||||
Body string
|
||||
ExpectedStatus int
|
||||
ExpectedJSON string
|
||||
}{
|
||||
{"GET", "/api/v0/compose/queue", ``, http.StatusOK, `*`}, // TODO: we need a way to verify we actually get the expected json here
|
||||
}
|
||||
|
||||
if len(os.Getenv("OSBUILD_COMPOSER_TEST_EXTERNAL")) > 0 {
|
||||
t.Skip("This test is for internal testing only")
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
s := store.New(nil)
|
||||
api := weldr.New(repo, packages, nil, s)
|
||||
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"}`)
|
||||
// create job and leave it running
|
||||
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"}`)
|
||||
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"}`)
|
||||
job = s.PopCompose()
|
||||
s.UpdateCompose(job.ComposeID, "FAILED")
|
||||
testRoute(t, api, false, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)
|
||||
sendHTTP(api, false, "DELETE", "/api/v0/blueprints/delete/test", ``)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue