@@ -203,6 +203,70 @@ const (
203203 }
204204 }
205205}
206+ `
207+ expectedCreateJobRequestBodyWithCapabilities = `
208+ {
209+ "param": {
210+ "dataplane_id": "123e4567-e89b-12d3-a456-426614174000",
211+ "description": "job desc",
212+ "name": "job-2",
213+ "nodepool": "np-2",
214+ "services": [
215+ {
216+ "id": "service-1",
217+ "env": {
218+ "DEFAULT_MOUNTNAME": "data"
219+ }
220+ },
221+ {
222+ "id": "service-2",
223+ "env": {
224+ "DEFAULT_MOUNTNAME": "data"
225+ }
226+ }
227+ ],
228+ "spec": {
229+ "tasks": {
230+ "default": {
231+ "cmds": [
232+ "run.sh"
233+ ]
234+ }
235+ },
236+ "version": "3"
237+ },
238+ "workspaces": [
239+ {
240+ "id": "ctrl-home",
241+ "mountName": "sas"
242+ },
243+ {
244+ "id": "ctrl-data",
245+ "mountName": "data"
246+ }
247+ ],
248+ "mounts": [
249+ {
250+ "capability": {
251+ "id": "capability1"
252+ }
253+ },
254+ {
255+ "capability": {
256+ "id": "capability2"
257+ }
258+ }
259+ ],
260+ "properties": {
261+ "isWorkbenchAppCreated": true,
262+ "primaryVolume": {
263+ "controller_id": "ctrl-home",
264+ "folderName": "sas",
265+ "id": "ws-home"
266+ }
267+ }
268+ }
269+ }
206270`
207271 expectedUpdateJobDryRunOutput = `{
208272 "ids": [
@@ -405,20 +469,21 @@ const (
405469)
406470
407471type createInput struct {
408- endpoint string
409- filename string
410- fileContent string
411- dryRun bool
412- dataplane string
413- name string
414- description string
415- context string
416- command string
417- application string
418- services []string
419- nodepool string
420- subPath string
421- workspaces []string
472+ endpoint string
473+ filename string
474+ fileContent string
475+ dryRun bool
476+ dataplane string
477+ name string
478+ description string
479+ context string
480+ command string
481+ application string
482+ services []string
483+ nodepool string
484+ subPath string
485+ workspaces []string
486+ capabilities []string
422487}
423488
424489type createExpected struct {
@@ -598,6 +663,42 @@ func TestCreateJobCommand(t *testing.T) {
598663 workspacesCalls : 2 ,
599664 },
600665 },
666+ {
667+ name : "create success with capabilities" ,
668+ input : createInput {
669+ dataplane : "123e4567-e89b-12d3-a456-426614174000" ,
670+ name : "job-2" ,
671+ description : "job desc" ,
672+ command : "run.sh" ,
673+ services : []string {"service-1" , "service-2" },
674+ nodepool : "np-2" ,
675+ workspaces : []string {"ws-home" , "ws-data" },
676+ capabilities : []string {"capability1" , "capability2" },
677+ },
678+ mockEndpoints : getCreateJobEndpoints (jobEndpointsConfig {
679+ dataplaneConfig : stubs.StubHTTPPartialGetConfig {
680+ ExpectedQuery : expectedDataplaneQuery ,
681+ ResponseBody : `[{"id":"123e4567-e89b-12d3-a456-426614174000"}]` ,
682+ ResponseStatus : http .StatusOK ,
683+ },
684+ servicesConfig : stubs.StubHTTPPartialGetConfig {
685+ ResponseBody : expectedServicesResponseBody ,
686+ ResponseStatus : http .StatusOK ,
687+ },
688+ jobConfig : stubs.StubHTTPPartialPostConfig {
689+ ExpectedRequestBody : expectedCreateJobRequestBodyWithCapabilities ,
690+ ResponseBody : `{"id":"job-1"}` ,
691+ ResponseStatus : http .StatusOK ,
692+ },
693+ }),
694+ expected : createExpected {
695+ displays : []string {stubs .ExpectedDeviceAuthDisplay , expectedCreateJobID },
696+ createCalls : 1 ,
697+ dataplanesCalls : 1 ,
698+ servicesCalls : 1 ,
699+ workspacesCalls : 2 ,
700+ },
701+ },
601702 {
602703 name : "create error" ,
603704 input : createInput {
@@ -1303,6 +1404,9 @@ func getCreateArgs(
13031404 for _ , workspaceID := range tt .input .workspaces {
13041405 args = append (args , "--" + constants .WorkspaceFlag , workspaceID )
13051406 }
1407+ for _ , capabilityID := range tt .input .capabilities {
1408+ args = append (args , "--" + constants .CapabilityFlag , capabilityID )
1409+ }
13061410 return args
13071411}
13081412
0 commit comments