From 04025cab1ac453fc62b16f51a3ddb002e5c257d4 Mon Sep 17 00:00:00 2001 From: Julio Fernandez Date: Mon, 29 Nov 2021 13:47:33 +0100 Subject: [PATCH 1/4] feature: Add command alias --- .../seqera/tower/cli/commands/ActionsCmd.java | 1 + .../tower/cli/commands/CollaboratorsCmd.java | 1 + .../tower/cli/commands/ComputeEnvsCmd.java | 1 + .../tower/cli/commands/CredentialsCmd.java | 1 + .../seqera/tower/cli/commands/MembersCmd.java | 1 + .../tower/cli/commands/OrganizationsCmd.java | 1 + .../tower/cli/commands/ParticipantsCmd.java | 1 + .../tower/cli/commands/PipelinesCmd.java | 1 + .../io/seqera/tower/cli/commands/RunsCmd.java | 1 + .../seqera/tower/cli/commands/TeamsCmd.java | 1 + .../tower/cli/commands/WorkspacesCmd.java | 1 + .../tower/cli/actions/ActionsCmdTest.java | 96 +++++++++++++++++ .../collaborators/CollaboratorsCmdTest.java | 46 ++++++++ .../cli/computeenvs/ComputeEnvsCmdTest.java | 13 +++ .../cli/credentials/CredentialsCmdTest.java | 13 +++ .../tower/cli/members/MembersCmdTest.java | 44 ++++++++ .../organizations/OrganizationsCmdTest.java | 33 ++++++ .../cli/participants/ParticipantsCmdTest.java | 102 ++++++++++++++++++ .../tower/cli/pipelines/PipelinesCmdTest.java | 21 ++++ .../io/seqera/tower/cli/runs/RunsCmdTest.java | 13 +++ .../seqera/tower/cli/teams/TeamsCmdTest.java | 54 ++++++++++ .../cli/workspaces/WorkspacesCmdTest.java | 33 ++++++ 22 files changed, 479 insertions(+) diff --git a/src/main/java/io/seqera/tower/cli/commands/ActionsCmd.java b/src/main/java/io/seqera/tower/cli/commands/ActionsCmd.java index 04ddea6f..9ebdeadb 100644 --- a/src/main/java/io/seqera/tower/cli/commands/ActionsCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/ActionsCmd.java @@ -20,6 +20,7 @@ @CommandLine.Command( name = "actions", + aliases = {"action"}, description = "Manage actions.", subcommands = { ListCmd.class, diff --git a/src/main/java/io/seqera/tower/cli/commands/CollaboratorsCmd.java b/src/main/java/io/seqera/tower/cli/commands/CollaboratorsCmd.java index 467cac12..2835c6d3 100644 --- a/src/main/java/io/seqera/tower/cli/commands/CollaboratorsCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/CollaboratorsCmd.java @@ -16,6 +16,7 @@ @CommandLine.Command( name = "collaborators", + aliases = {"collab"}, description = "Manage organization collaborators.", subcommands = { ListCmd.class, diff --git a/src/main/java/io/seqera/tower/cli/commands/ComputeEnvsCmd.java b/src/main/java/io/seqera/tower/cli/commands/ComputeEnvsCmd.java index 734dfb9a..87588403 100644 --- a/src/main/java/io/seqera/tower/cli/commands/ComputeEnvsCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/ComputeEnvsCmd.java @@ -23,6 +23,7 @@ @Command( name = "compute-envs", + aliases = {"ce"}, description = "Manage workspace compute environments.", subcommands = { AddCmd.class, diff --git a/src/main/java/io/seqera/tower/cli/commands/CredentialsCmd.java b/src/main/java/io/seqera/tower/cli/commands/CredentialsCmd.java index 687ee970..0c692b2f 100644 --- a/src/main/java/io/seqera/tower/cli/commands/CredentialsCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/CredentialsCmd.java @@ -20,6 +20,7 @@ @Command( name = "credentials", + aliases = {"cred"}, description = "Manage workspace credentials.", subcommands = { AddCmd.class, diff --git a/src/main/java/io/seqera/tower/cli/commands/MembersCmd.java b/src/main/java/io/seqera/tower/cli/commands/MembersCmd.java index 29aa4656..e304e45a 100644 --- a/src/main/java/io/seqera/tower/cli/commands/MembersCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/MembersCmd.java @@ -20,6 +20,7 @@ @CommandLine.Command( name = "members", + aliases = {"member"}, description = "Manage organization members.", subcommands = { ListCmd.class, diff --git a/src/main/java/io/seqera/tower/cli/commands/OrganizationsCmd.java b/src/main/java/io/seqera/tower/cli/commands/OrganizationsCmd.java index 45a421ff..ec3f27b0 100644 --- a/src/main/java/io/seqera/tower/cli/commands/OrganizationsCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/OrganizationsCmd.java @@ -20,6 +20,7 @@ @CommandLine.Command( name = "organizations", + aliases = {"org"}, description = "Manage organizations.", subcommands = { ListCmd.class, diff --git a/src/main/java/io/seqera/tower/cli/commands/ParticipantsCmd.java b/src/main/java/io/seqera/tower/cli/commands/ParticipantsCmd.java index 5f2cdff0..00f8a343 100644 --- a/src/main/java/io/seqera/tower/cli/commands/ParticipantsCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/ParticipantsCmd.java @@ -20,6 +20,7 @@ @CommandLine.Command( name = "participants", + aliases = {"part"}, description = "Manage workspace participants.", subcommands = { ListCmd.class, diff --git a/src/main/java/io/seqera/tower/cli/commands/PipelinesCmd.java b/src/main/java/io/seqera/tower/cli/commands/PipelinesCmd.java index 2456aab5..224be108 100644 --- a/src/main/java/io/seqera/tower/cli/commands/PipelinesCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/PipelinesCmd.java @@ -23,6 +23,7 @@ @Command( name = "pipelines", + aliases = {"pipe"}, description = "Manage workspace pipeline launchpad.", subcommands = { ListCmd.class, diff --git a/src/main/java/io/seqera/tower/cli/commands/RunsCmd.java b/src/main/java/io/seqera/tower/cli/commands/RunsCmd.java index d565d751..10bee5f7 100644 --- a/src/main/java/io/seqera/tower/cli/commands/RunsCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/RunsCmd.java @@ -20,6 +20,7 @@ @CommandLine.Command( name = "runs", + aliases = {"run"}, description = "Manage workspace pipeline runs.", subcommands = { ViewCmd.class, diff --git a/src/main/java/io/seqera/tower/cli/commands/TeamsCmd.java b/src/main/java/io/seqera/tower/cli/commands/TeamsCmd.java index 681005c3..a6e6663f 100644 --- a/src/main/java/io/seqera/tower/cli/commands/TeamsCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/TeamsCmd.java @@ -20,6 +20,7 @@ @CommandLine.Command( name = "teams", + aliases = {"team"}, description = "Manage organization teams.", subcommands = { ListCmd.class, diff --git a/src/main/java/io/seqera/tower/cli/commands/WorkspacesCmd.java b/src/main/java/io/seqera/tower/cli/commands/WorkspacesCmd.java index 6486f7f0..b2a4ccbe 100644 --- a/src/main/java/io/seqera/tower/cli/commands/WorkspacesCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/WorkspacesCmd.java @@ -21,6 +21,7 @@ @CommandLine.Command( name = "workspaces", + aliases = {"wsp"}, description = "Manage workspaces.", subcommands = { ListCmd.class, diff --git a/src/test/java/io/seqera/tower/cli/actions/ActionsCmdTest.java b/src/test/java/io/seqera/tower/cli/actions/ActionsCmdTest.java index 983eb1cd..459775d6 100644 --- a/src/test/java/io/seqera/tower/cli/actions/ActionsCmdTest.java +++ b/src/test/java/io/seqera/tower/cli/actions/ActionsCmdTest.java @@ -226,6 +226,102 @@ void testView(OutputType format, MockServerClient mock) throws JsonProcessingExc " }", Action.class))); } + @ParameterizedTest + @EnumSource(OutputType.class) + void testViewAlias(OutputType format, MockServerClient mock) throws JsonProcessingException { + mock.reset(); + + mock.when( + request().withMethod("GET").withPath("/actions"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("actions/actions_list")).withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/actions/57byWxhmUDLLWIF4J97XEP"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("actions/action_view")).withContentType(MediaType.APPLICATION_JSON) + ); + + ExecOut out = exec(format, mock, "action", "view", "-n", "hello"); + assertOutput(format, out, new ActionsView(parseJson("{\n" + + " \"id\": \"57byWxhmUDLLWIF4J97XEP\",\n" + + " \"launch\": {\n" + + " \"id\": \"3htPtgK2KufwvQcovOko\",\n" + + " \"computeEnv\": {\n" + + " \"id\": \"1NcvsrdHeaKsrpgQ85NYpe\",\n" + + " \"name\": \"deleted-774901692352490\",\n" + + " \"description\": null,\n" + + " \"platform\": \"slurm-platform\",\n" + + " \"config\": {\n" + + " \"hostName\": \"slurm.seqera.io\",\n" + + " \"workDir\": \"/home/ubuntu/nf-work\",\n" + + " \"userName\": \"ubuntu\",\n" + + " \"preRunScript\": null,\n" + + " \"postRunScript\": null,\n" + + " \"headQueue\": \"long\",\n" + + " \"launchDir\": \"/home/ubuntu/nf-work\",\n" + + " \"headJobOptions\": null,\n" + + " \"computeQueue\": null,\n" + + " \"port\": null,\n" + + " \"maxQueueSize\": null,\n" + + " \"discriminator\": \"slurm-platform\"\n" + + " },\n" + + " \"dateCreated\": \"2021-06-18T08:58:21Z\",\n" + + " \"lastUpdated\": \"2021-06-18T08:58:21Z\",\n" + + " \"lastUsed\": \"2021-06-18T10:22:31Z\",\n" + + " \"deleted\": true,\n" + + " \"status\": \"AVAILABLE\",\n" + + " \"message\": null,\n" + + " \"primary\": null,\n" + + " \"credentialsId\": \"5KmzwVT34sT8ItofmP5S\"\n" + + " },\n" + + " \"pipeline\": \"https://github.com/pditommaso/hello\",\n" + + " \"workDir\": \"/home/ubuntu/nf-work\",\n" + + " \"revision\": null,\n" + + " \"configText\": null,\n" + + " \"paramsText\": null,\n" + + " \"preRunScript\": null,\n" + + " \"postRunScript\": null,\n" + + " \"mainScript\": null,\n" + + " \"entryName\": null,\n" + + " \"schemaName\": null,\n" + + " \"resume\": false,\n" + + " \"pullLatest\": false,\n" + + " \"stubRun\": false,\n" + + " \"sessionId\": null,\n" + + " \"configProfiles\": null,\n" + + " \"dateCreated\": \"2021-06-18T10:10:05Z\",\n" + + " \"lastUpdated\": \"2021-06-18T10:10:05Z\"\n" + + " },\n" + + " \"name\": \"hello\",\n" + + " \"hookId\": \"303166158\",\n" + + " \"hookUrl\": \"https://api.github.com/repos/pditommaso/hello/hooks/303166158\",\n" + + " \"message\": null,\n" + + " \"deleted\": null,\n" + + " \"source\": \"github\",\n" + + " \"status\": \"ACTIVE\",\n" + + " \"config\": {\n" + + " \"events\": [\n" + + " \"push\"\n" + + " ],\n" + + " \"discriminator\": \"github\"\n" + + " },\n" + + " \"event\": {\n" + + " \"ref\": \"refs/heads/master\",\n" + + " \"commitId\": \"af8d93083a36552914929a959f7576f62996032e\",\n" + + " \"commitMessage\": \"Update README.md\",\n" + + " \"pusherName\": \"pditommaso\",\n" + + " \"pusherEmail\": \"paolo.ditommaso@gmail.com\",\n" + + " \"timestamp\": \"2021-06-18T12:10:32+02:00\",\n" + + " \"discriminator\": \"github\"\n" + + " },\n" + + " \"lastSeen\": \"2021-06-18T10:10:33Z\",\n" + + " \"dateCreated\": \"2021-06-18T10:10:05Z\",\n" + + " \"lastUpdated\": \"2021-06-18T10:10:33Z\"\n" + + " }", Action.class))); + } + @Test void testViewNoActionFound(MockServerClient mock) { mock.reset(); diff --git a/src/test/java/io/seqera/tower/cli/collaborators/CollaboratorsCmdTest.java b/src/test/java/io/seqera/tower/cli/collaborators/CollaboratorsCmdTest.java index fc039097..328da733 100644 --- a/src/test/java/io/seqera/tower/cli/collaborators/CollaboratorsCmdTest.java +++ b/src/test/java/io/seqera/tower/cli/collaborators/CollaboratorsCmdTest.java @@ -78,4 +78,50 @@ void testListCollaborators(OutputType format, MockServerClient mock) throws Json " }", MemberDbDto.class) ))); } + + @ParameterizedTest + @EnumSource(OutputType.class) + void testListCollaboratorsAlias(OutputType format, MockServerClient mock) throws JsonProcessingException { + mock.when( + request().withMethod("GET").withPath("/user"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("user")).withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/user/1264/workspaces"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("workspaces/workspaces_list")).withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/orgs/27736513644467/collaborators") + .withQueryStringParameter("max", "100") + .withQueryStringParameter("offset", "0"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("collaborators/collaborators_list")).withContentType(MediaType.APPLICATION_JSON) + ); + + ExecOut out = exec(format, mock, "collab", "list", "-o", "27736513644467"); + assertOutput(format, out, new CollaboratorsList(27736513644467L, Arrays.asList( + parseJson(" {\n" + + " \"memberId\": 175703974560466,\n" + + " \"userName\": \"jfernandez74\",\n" + + " \"email\": \"jfernandez74@gmail.com\",\n" + + " \"firstName\": null,\n" + + " \"lastName\": null,\n" + + " \"avatar\": \"https://www.gravatar.com/avatar/7d3c1ee212a3465233e161b451fb4d05?d=404\",\n" + + " \"role\" : \"collaborator\"" + + " }", MemberDbDto.class), + parseJson("{\n" + + " \"memberId\": 255080245994226,\n" + + " \"userName\": \"julio\",\n" + + " \"email\": \"julio@seqera.io\",\n" + + " \"firstName\": null,\n" + + " \"lastName\": null,\n" + + " \"avatar\": \"https://www.gravatar.com/avatar/72918a9f674eaa696729917bec58760b?d=404\",\n" + + " \"role\" : \"collaborator\"" + + " }", MemberDbDto.class) + ))); + } } diff --git a/src/test/java/io/seqera/tower/cli/computeenvs/ComputeEnvsCmdTest.java b/src/test/java/io/seqera/tower/cli/computeenvs/ComputeEnvsCmdTest.java index cb9c125f..0b48f2d8 100644 --- a/src/test/java/io/seqera/tower/cli/computeenvs/ComputeEnvsCmdTest.java +++ b/src/test/java/io/seqera/tower/cli/computeenvs/ComputeEnvsCmdTest.java @@ -72,6 +72,19 @@ void testDelete(OutputType format, MockServerClient mock) { assertOutput(format, out, new ComputeEnvDeleted("vYOK4vn7spw7bHHWBDXZ2", USER_WORKSPACE_NAME)); } + @ParameterizedTest + @EnumSource(OutputType.class) + void testDeleteAlias(OutputType format, MockServerClient mock) { + mock.when( + request().withMethod("DELETE").withPath("/compute-envs/vYOK4vn7spw7bHHWBDXZ2"), exactly(1) + ).respond( + response().withStatusCode(204) + ); + + ExecOut out = exec(format, mock, "ce", "delete", "-i", "vYOK4vn7spw7bHHWBDXZ2"); + assertOutput(format, out, new ComputeEnvDeleted("vYOK4vn7spw7bHHWBDXZ2", USER_WORKSPACE_NAME)); + } + @Test void testDeleteInvalidAuth(MockServerClient mock) { mock.when( diff --git a/src/test/java/io/seqera/tower/cli/credentials/CredentialsCmdTest.java b/src/test/java/io/seqera/tower/cli/credentials/CredentialsCmdTest.java index 9e3f8210..497cd6d7 100644 --- a/src/test/java/io/seqera/tower/cli/credentials/CredentialsCmdTest.java +++ b/src/test/java/io/seqera/tower/cli/credentials/CredentialsCmdTest.java @@ -56,6 +56,19 @@ void testDelete(OutputType format, MockServerClient mock) { assertOutput(format, out, new CredentialsDeleted("1cz5A8cuBkB5iJliCwJCFU", USER_WORKSPACE_NAME)); } + @ParameterizedTest + @EnumSource(OutputType.class) + void testDeleteAlias(OutputType format, MockServerClient mock) { + mock.when( + request().withMethod("DELETE").withPath("/credentials/1cz5A8cuBkB5iJliCwJCFU"), exactly(1) + ).respond( + response().withStatusCode(204) + ); + + ExecOut out = exec(format, mock, "cred", "delete", "-i", "1cz5A8cuBkB5iJliCwJCFU"); + assertOutput(format, out, new CredentialsDeleted("1cz5A8cuBkB5iJliCwJCFU", USER_WORKSPACE_NAME)); + } + @Test void testDeleteNotFound(MockServerClient mock) { mock.when( diff --git a/src/test/java/io/seqera/tower/cli/members/MembersCmdTest.java b/src/test/java/io/seqera/tower/cli/members/MembersCmdTest.java index 1dc68725..efd3441b 100644 --- a/src/test/java/io/seqera/tower/cli/members/MembersCmdTest.java +++ b/src/test/java/io/seqera/tower/cli/members/MembersCmdTest.java @@ -82,6 +82,50 @@ void testList(OutputType format, MockServerClient mock) throws JsonProcessingExc ))); } + @ParameterizedTest + @EnumSource(OutputType.class) + void testListAlias(OutputType format, MockServerClient mock) throws JsonProcessingException { + mock.when( + request().withMethod("GET").withPath("/user"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("user")).withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/user/1264/workspaces"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("workspaces/workspaces_list")).withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/orgs/27736513644467/members"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("members/members_list")).withContentType(MediaType.APPLICATION_JSON) + ); + + ExecOut out = exec(format, mock, "member", "list", "-o", "organization1"); + assertOutput(format, out, new MembersList("organization1", Arrays.asList( + parseJson(" {\n" + + " \"memberId\": 175703974560466,\n" + + " \"userName\": \"jfernandez74\",\n" + + " \"email\": \"jfernandez74@gmail.com\",\n" + + " \"firstName\": null,\n" + + " \"lastName\": null,\n" + + " \"avatar\": \"https://www.gravatar.com/avatar/7d3c1ee212a3465233e161b451fb4d05?d=404\",\n" + + " \"role\": \"owner\"\n" + + " }", MemberDbDto.class), + parseJson("{\n" + + " \"memberId\": 255080245994226,\n" + + " \"userName\": \"julio\",\n" + + " \"email\": \"julio@seqera.io\",\n" + + " \"firstName\": null,\n" + + " \"lastName\": null,\n" + + " \"avatar\": \"https://www.gravatar.com/avatar/72918a9f674eaa696729917bec58760b?d=404\",\n" + + " \"role\": \"member\"\n" + + " }", MemberDbDto.class) + ))); + } + @Test void testListWithOffset(MockServerClient mock) throws JsonProcessingException { mock.when( diff --git a/src/test/java/io/seqera/tower/cli/organizations/OrganizationsCmdTest.java b/src/test/java/io/seqera/tower/cli/organizations/OrganizationsCmdTest.java index 9fa881e7..00aaa24c 100644 --- a/src/test/java/io/seqera/tower/cli/organizations/OrganizationsCmdTest.java +++ b/src/test/java/io/seqera/tower/cli/organizations/OrganizationsCmdTest.java @@ -74,6 +74,39 @@ void testList(OutputType format, MockServerClient mock) throws JsonProcessingExc ))); } + @ParameterizedTest + @EnumSource(OutputType.class) + void testListAlias(OutputType format, MockServerClient mock) throws JsonProcessingException { + mock.when( + request().withMethod("GET").withPath("/user"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("user")).withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/user/1264/workspaces"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("workspaces/workspaces_list")).withContentType(MediaType.APPLICATION_JSON) + ); + + ExecOut out = exec(format, mock, "org", "list"); + assertOutput(format, out, new OrganizationsList("jordi", Arrays.asList(parseJson(" {\n" + + " \"orgId\": 27736513644467,\n" + + " \"orgName\": \"organization1\",\n" + + " \"orgLogoUrl\": null,\n" + + " \"workspaceId\": null,\n" + + " \"workspaceName\": null\n" + + " }", OrgAndWorkspaceDbDto.class), + parseJson(" {\n" + + " \"orgId\": 37736513644467,\n" + + " \"orgName\": \"organization2\",\n" + + " \"orgLogoUrl\": null,\n" + + " \"workspaceId\": null,\n" + + " \"workspaceName\": null\n" + + " }", OrgAndWorkspaceDbDto.class) + ))); + } + @Test void testListEmpty(MockServerClient mock) { mock.when( diff --git a/src/test/java/io/seqera/tower/cli/participants/ParticipantsCmdTest.java b/src/test/java/io/seqera/tower/cli/participants/ParticipantsCmdTest.java index 7db42719..55c1a3c2 100644 --- a/src/test/java/io/seqera/tower/cli/participants/ParticipantsCmdTest.java +++ b/src/test/java/io/seqera/tower/cli/participants/ParticipantsCmdTest.java @@ -142,6 +142,108 @@ void testList(OutputType format, MockServerClient mock) throws JsonProcessingExc " }", ParticipantDbDto.class)))); } + @ParameterizedTest + @EnumSource(OutputType.class) + void testListAlias(OutputType format, MockServerClient mock) throws JsonProcessingException { + mock.when( + request().withMethod("GET").withPath("/user"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("user")).withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/user/1264/workspaces"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("workspaces/workspaces_list")).withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/orgs/27736513644467/workspaces/75887156211589/participants"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("participants/participants_list")).withContentType(MediaType.APPLICATION_JSON) + ); + + ExecOut out = exec(format, mock, "part", "list", "-w", "75887156211589"); + + assertOutput(format, out, new ParticipantsList("organization1", "workspace1", + Arrays.asList( + parseJson("{\n" + + " \"participantId\": 48516118433516,\n" + + " \"memberId\": 175703974560466,\n" + + " \"userName\": \"jfernandez74\",\n" + + " \"firstName\": null,\n" + + " \"lastName\": null,\n" + + " \"email\": \"jfernandez74@gmail.com\",\n" + + " \"orgRole\": \"owner\",\n" + + " \"teamId\": null,\n" + + " \"teamName\": null,\n" + + " \"wspRole\": \"owner\",\n" + + " \"type\": \"MEMBER\",\n" + + " \"teamAvatarUrl\": null,\n" + + " \"userAvatarUrl\": \"https://www.gravatar.com/avatar/7d3c1ee212a3465233e161b451fb4d05?d=404\"\n" + + " }", ParticipantDbDto.class), + parseJson(" {\n" + + " \"participantId\": 36791779798370,\n" + + " \"memberId\": 255080245994226,\n" + + " \"userName\": \"julio\",\n" + + " \"firstName\": null,\n" + + " \"lastName\": null,\n" + + " \"email\": \"julio@seqera.io\",\n" + + " \"orgRole\": \"member\",\n" + + " \"teamId\": null,\n" + + " \"teamName\": null,\n" + + " \"wspRole\": \"admin\",\n" + + " \"type\": \"MEMBER\",\n" + + " \"teamAvatarUrl\": null,\n" + + " \"userAvatarUrl\": \"https://www.gravatar.com/avatar/72918a9f674eaa696729917bec58760b?d=404\"\n" + + " }", ParticipantDbDto.class), + parseJson("{\n" + + " \"participantId\": 110330443206779,\n" + + " \"memberId\": 80726606082762,\n" + + " \"userName\": \"julio2\",\n" + + " \"firstName\": null,\n" + + " \"lastName\": null,\n" + + " \"email\": \"julio2@seqera.io\",\n" + + " \"orgRole\": \"member\",\n" + + " \"teamId\": null,\n" + + " \"teamName\": null,\n" + + " \"wspRole\": \"launch\",\n" + + " \"type\": \"MEMBER\",\n" + + " \"teamAvatarUrl\": null,\n" + + " \"userAvatarUrl\": null\n" + + " }", ParticipantDbDto.class), + parseJson("{\n" + + " \"participantId\": 110330443206780,\n" + + " \"memberId\": 80726606082770,\n" + + " \"userName\": \"jordi\",\n" + + " \"firstName\": null,\n" + + " \"lastName\": null,\n" + + " \"email\": \"jordi@seqera.io\",\n" + + " \"orgRole\": \"member\",\n" + + " \"teamId\": null,\n" + + " \"teamName\": null,\n" + + " \"wspRole\": \"launch\",\n" + + " \"type\": \"MEMBER\",\n" + + " \"teamAvatarUrl\": null,\n" + + " \"userAvatarUrl\": null\n" + + " }", ParticipantDbDto.class), + parseJson("{\n" + + " \"participantId\": 179548688376545,\n" + + " \"memberId\": null,\n" + + " \"userName\": null,\n" + + " \"firstName\": null,\n" + + " \"lastName\": null,\n" + + " \"email\": null,\n" + + " \"orgRole\": null,\n" + + " \"teamId\": 255717345477198,\n" + + " \"teamName\": \"team-test-2\",\n" + + " \"wspRole\": \"launch\",\n" + + " \"type\": \"TEAM\",\n" + + " \"teamAvatarUrl\": null,\n" + + " \"userAvatarUrl\": null\n" + + " }", ParticipantDbDto.class)))); + } + @Test void testListWithOffset(MockServerClient mock) throws JsonProcessingException { mock.when( diff --git a/src/test/java/io/seqera/tower/cli/pipelines/PipelinesCmdTest.java b/src/test/java/io/seqera/tower/cli/pipelines/PipelinesCmdTest.java index ca9d2343..98ea83cb 100644 --- a/src/test/java/io/seqera/tower/cli/pipelines/PipelinesCmdTest.java +++ b/src/test/java/io/seqera/tower/cli/pipelines/PipelinesCmdTest.java @@ -251,6 +251,27 @@ void testDelete(MockServerClient mock) { assertEquals(0, out.exitCode); } + @Test + void testDeleteAlias(MockServerClient mock) { + mock.when( + request().withMethod("GET").withPath("/pipelines").withQueryStringParameter("search", "sleep"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("pipelines_sleep")).withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("DELETE").withPath("/pipelines/183522618315672"), exactly(1) + ).respond( + response().withStatusCode(204) + ); + + ExecOut out = exec(mock, "pipe", "delete", "-n", "sleep"); + + assertEquals("", out.stdErr); + assertEquals(new PipelinesDeleted("sleep", USER_WORKSPACE_NAME).toString(), out.stdOut); + assertEquals(0, out.exitCode); + } + @Test void testDeleteNotFound(MockServerClient mock) { mock.when( diff --git a/src/test/java/io/seqera/tower/cli/runs/RunsCmdTest.java b/src/test/java/io/seqera/tower/cli/runs/RunsCmdTest.java index 3c640239..80bda8ef 100644 --- a/src/test/java/io/seqera/tower/cli/runs/RunsCmdTest.java +++ b/src/test/java/io/seqera/tower/cli/runs/RunsCmdTest.java @@ -68,6 +68,19 @@ void testDelete(OutputType format, MockServerClient mock) { assertOutput(format, out, new RunDeleted("5dAZoXrcmZXRO4", USER_WORKSPACE_NAME)); } + @ParameterizedTest + @EnumSource(OutputType.class) + void testDeleteAlias(OutputType format, MockServerClient mock) { + mock.when( + request().withMethod("DELETE").withPath("/workflow/5dAZoXrcmZXRO4"), exactly(1) + ).respond( + response().withStatusCode(204) + ); + + ExecOut out = exec(format, mock, "run", "delete", "-i", "5dAZoXrcmZXRO4"); + assertOutput(format, out, new RunDeleted("5dAZoXrcmZXRO4", USER_WORKSPACE_NAME)); + } + @Test void testDeleteNotFound(MockServerClient mock) { mock.when( diff --git a/src/test/java/io/seqera/tower/cli/teams/TeamsCmdTest.java b/src/test/java/io/seqera/tower/cli/teams/TeamsCmdTest.java index 31171e0c..abc17993 100644 --- a/src/test/java/io/seqera/tower/cli/teams/TeamsCmdTest.java +++ b/src/test/java/io/seqera/tower/cli/teams/TeamsCmdTest.java @@ -92,6 +92,60 @@ void testList(OutputType format, MockServerClient mock) throws JsonProcessingExc ))); } + @ParameterizedTest + @EnumSource(OutputType.class) + void testListAlias(OutputType format, MockServerClient mock) throws JsonProcessingException { + mock.when( + request().withMethod("GET").withPath("/user"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("user")).withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/user/1264/workspaces"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("workspaces/workspaces_list")).withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/orgs/27736513644467/teams"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("teams/teams_list")).withContentType(MediaType.APPLICATION_JSON) + ); + + ExecOut out = exec(format, mock, "team", "list", "-o", "organization1"); + assertOutput(format, out, new TeamsList("organization1", Arrays.asList( + parseJson(" {\n" + + " \"teamId\": 249211453903161,\n" + + " \"name\": \"team-test-3\",\n" + + " \"description\": \"AAAAAA\",\n" + + " \"avatarUrl\": null,\n" + + " \"membersCount\": 0\n" + + " }", TeamDbDto.class), + parseJson(" {\n" + + " \"teamId\": 69076469523589,\n" + + " \"name\": \"team-test-1\",\n" + + " \"description\": \"a new team\",\n" + + " \"avatarUrl\": null,\n" + + " \"membersCount\": 0\n" + + " }", TeamDbDto.class), + parseJson(" {\n" + + " \"teamId\": 255717345477198,\n" + + " \"name\": \"team-test-2\",\n" + + " \"description\": \"a new team\",\n" + + " \"avatarUrl\": null,\n" + + " \"membersCount\": 0\n" + + " }", TeamDbDto.class), + parseJson("{\n" + + " \"teamId\": 267477500890054,\n" + + " \"name\": \"team1\",\n" + + " \"description\": \"Team 1\",\n" + + " \"avatarUrl\": null,\n" + + " \"membersCount\": 1\n" + + " }", TeamDbDto.class) + ))); + } + @Test void testListWithOffset(MockServerClient mock) throws JsonProcessingException { mock.when( diff --git a/src/test/java/io/seqera/tower/cli/workspaces/WorkspacesCmdTest.java b/src/test/java/io/seqera/tower/cli/workspaces/WorkspacesCmdTest.java index 0c42a684..3946254a 100644 --- a/src/test/java/io/seqera/tower/cli/workspaces/WorkspacesCmdTest.java +++ b/src/test/java/io/seqera/tower/cli/workspaces/WorkspacesCmdTest.java @@ -76,6 +76,39 @@ void testList(OutputType format, MockServerClient mock) throws JsonProcessingExc ))); } + @ParameterizedTest + @EnumSource(OutputType.class) + void testListAlias(OutputType format, MockServerClient mock) throws JsonProcessingException { + mock.when( + request().withMethod("GET").withPath("/user"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("user")).withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/user/1264/workspaces"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("workspaces/workspaces_list")).withContentType(MediaType.APPLICATION_JSON) + ); + + ExecOut out = exec(format, mock, "wsp", "list"); + assertOutput(format, out, new WorkspaceList("jordi", Arrays.asList(parseJson(" {\n" + + " \"orgId\": 27736513644467,\n" + + " \"orgName\": \"organization1\",\n" + + " \"orgLogoUrl\": null,\n" + + " \"workspaceId\": 75887156211589,\n" + + " \"workspaceName\": \"workspace1\"\n" + + " }", OrgAndWorkspaceDbDto.class), + parseJson("{\n" + + " \"orgId\": 37736513644467,\n" + + " \"orgName\": \"organization2\",\n" + + " \"orgLogoUrl\": null,\n" + + " \"workspaceId\": 75887156211590,\n" + + " \"workspaceName\": \"workspace2\"\n" + + " }", OrgAndWorkspaceDbDto.class) + ))); + } + @ParameterizedTest @EnumSource(OutputType.class) void testListByOrganization(OutputType format, MockServerClient mock) throws JsonProcessingException { From 4a03a31c8f2db6ded4f155ed9f19c5306eb46423 Mon Sep 17 00:00:00 2001 From: Julio Fernandez Date: Tue, 30 Nov 2021 08:10:26 +0100 Subject: [PATCH 2/4] fix: fix compile readme instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d81ae1b..5f733117 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ The Tower CLI is a platform binary executable created by a native compilation fr 3. Create the native client: ```bash - ./gradlew nativeImage + ./gradlew nativeCompile ``` 4. Run `tw`: From 67b0ffbda294a53cbfe0aa00da66368660bde568 Mon Sep 17 00:00:00 2001 From: Julio Fernandez Date: Tue, 30 Nov 2021 08:12:30 +0100 Subject: [PATCH 3/4] fix: fix compile readme instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f733117..8cf52dd7 100644 --- a/README.md +++ b/README.md @@ -233,7 +233,7 @@ The Tower CLI is a platform binary executable created by a native compilation fr 4. Run `tw`: ```bash - ./build/graal/tw + ./build/native/nativeCompile/tw ``` ## Using non-binary development versions From f9bb7dd364692533fca91e2a0ed73259534b7592 Mon Sep 17 00:00:00 2001 From: Julio Fernandez Date: Tue, 30 Nov 2021 09:46:13 +0100 Subject: [PATCH 4/4] fix: picocli upgrade --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 99bd76b5..8bebd5f7 100644 --- a/build.gradle +++ b/build.gradle @@ -17,8 +17,8 @@ dependencies { implementation 'ch.qos.logback:logback-core:1.2.6' implementation 'ch.qos.logback:logback-classic:1.2.6' implementation 'io.seqera:tower-java-sdk:1.1.0' - implementation 'info.picocli:picocli:4.6.1' - annotationProcessor 'info.picocli:picocli-codegen:4.6.1' + implementation 'info.picocli:picocli:4.6.2' + annotationProcessor 'info.picocli:picocli-codegen:4.6.2' testImplementation 'org.mock-server:mockserver-client-java:5.11.2' testImplementation 'org.mock-server:mockserver-netty:5.11.2'