target: add constructor

We only support local target for now, but this avoids having to
open code it.

Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
Tom Gundersen 2019-09-27 15:54:13 +02:00
parent f880581a14
commit 5df6874b94
5 changed files with 20 additions and 19 deletions

View file

@ -66,7 +66,7 @@ func testRoute(t *testing.T, api *jobqueue.API, method, path, body string, expec
}
func TestBasic(t *testing.T) {
expected_job := `{"pipeline":{"assembler":{"name":"org.osbuild.tar","options":{"filename":"image.tar"}}},"targets":[{"name":"org.osbuild.local","options":{"location":"/var/lib/osbuild-composer/ffffffff-ffff-ffff-ffff-ffffffffffff"}}]}`
expected_job := `{"pipeline":{"assembler":{"name":"org.osbuild.tar","options":{"filename":"image.tar"}}},"targets":[{"name":"org.osbuild.local","options":{"location":"/var/lib/osbuild-composer/outputs/ffffffff-ffff-ffff-ffff-ffffffffffff"}}]}`
var cases = []struct {
Method string
Path string
@ -104,12 +104,7 @@ func TestBasic(t *testing.T) {
},
},
},
Targets: []target.Target{{
Name: "org.osbuild.local",
Options: target.LocalOptions{
Location: "/var/lib/osbuild-composer/ffffffff-ffff-ffff-ffff-ffffffffffff",
}},
},
Targets: []*target.Target{target.New(id)},
}
testRoute(t, api, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedJSON)