Search in sources :

Example 1 with UFWorkspaceLight

use of bio.terra.cli.serialization.userfacing.UFWorkspaceLight in project terra-cli by DataBiosphere.

the class WorkspaceOverride method workspace.

@Test
@DisplayName("workspace commands respect workspace override")
void workspace() throws IOException {
    workspaceCreator.login();
    // `terra workspace create`
    UFWorkspace workspace3 = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "create");
    // `terra workspace set --id=$id1`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + workspace1.id);
    // `terra workspace update --name=$newName --description=$newDescription --workspace=$id3`
    String newName = "workspace3_name_NEW";
    String newDescription = "workspace3 description NEW";
    TestCommand.runCommandExpectSuccess("workspace", "update", "--name=" + newName, "--description=" + newDescription, "--workspace=" + workspace3.id);
    // check that the workspace 3 description has been updated, and the workspace 1 has not
    // `terra workspace describe --workspace=$id3`
    UFWorkspace workspaceDescribe = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "describe", "--workspace=" + workspace3.id);
    assertEquals(newName, workspaceDescribe.name, "workspace 3 name matches update");
    assertEquals(newDescription, workspaceDescribe.description, "workspace 3 description matches update");
    // `terra workspace describe`
    workspaceDescribe = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "describe");
    assertEquals(workspace1.name, workspaceDescribe.name, "workspace 1 name matches create");
    assertEquals(workspace1.description, workspaceDescribe.description, "workspace 1 description matches create");
    // check the workspace 3 has been deleted, and workspace 1 has not
    // `terra workspace delete --workspace=$id3`
    TestCommand.runCommandExpectSuccess("workspace", "delete", "--workspace=" + workspace3.id, "--quiet");
    // `terra workspace list`
    List<UFWorkspaceLight> matchingWorkspaces = listWorkspacesWithId(workspace3.id);
    assertEquals(0, matchingWorkspaces.size(), "deleted workspace 3 is not included in list");
    // `terra workspace list`
    matchingWorkspaces = listWorkspacesWithId(workspace1.id);
    assertEquals(1, matchingWorkspaces.size(), "workspace 1 is still included in list");
}
Also used : UFWorkspaceLight(bio.terra.cli.serialization.userfacing.UFWorkspaceLight) UFWorkspace(bio.terra.cli.serialization.userfacing.UFWorkspace) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with UFWorkspaceLight

use of bio.terra.cli.serialization.userfacing.UFWorkspaceLight in project terra-cli by DataBiosphere.

the class Workspace method statusDescribeListReflectUpdate.

@Test
@DisplayName("status, describe, workspace list reflect workspace update")
void statusDescribeListReflectUpdate() throws IOException {
    // select a test user and login
    TestUser testUser = TestUser.chooseTestUserWithSpendAccess();
    testUser.login();
    // `terra workspace create --format=json --name=$name --description=$description`
    String name = "statusDescribeListReflectUpdate";
    String description = "status list reflect update";
    UFWorkspace createWorkspace = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "create", "--name=" + name, "--description=" + description);
    // check the created workspace name and description are set
    assertNotNull(createWorkspace.name, "create workspace name is defined");
    assertNotNull(createWorkspace.description, "create workspace description is defined");
    // `terra workspace create --format=json --name=$newName --description=$newDescription`
    String newName = "NEW_statusDescribeListReflectUpdate";
    String newDescription = "NEW status describe list reflect update";
    TestCommand.runCommandExpectSuccess("workspace", "update", "--format=json", "--name=" + newName, "--description=" + newDescription);
    // `terra status --format=json`
    UFStatus status = TestCommand.runAndParseCommandExpectSuccess(UFStatus.class, "status");
    // check the current status reflects the update
    assertEquals(newName, status.workspace.name, "status matches updated workspace name");
    assertEquals(newDescription, status.workspace.description, "status matches updated workspace description");
    // `terra workspace describe --format=json`
    UFWorkspace describeWorkspace = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "describe");
    // check the workspace describe reflects the update
    assertEquals(newName, describeWorkspace.name, "describe matches updated workspace name");
    assertEquals(newDescription, describeWorkspace.description, "describe matches updated workspace description");
    // check the workspace list reflects the update
    List<UFWorkspaceLight> matchingWorkspaces = listWorkspacesWithId(createWorkspace.id);
    assertEquals(1, matchingWorkspaces.size(), "updated workspace is included exactly once in list");
    assertEquals(newName, matchingWorkspaces.get(0).name, "updated workspace name matches that in list");
    assertEquals(newDescription, matchingWorkspaces.get(0).description, "updated workspace description matches that in list");
    // `terra workspace delete`
    TestCommand.runCommandExpectSuccess("workspace", "delete", "--quiet");
}
Also used : UFWorkspaceLight(bio.terra.cli.serialization.userfacing.UFWorkspaceLight) UFStatus(bio.terra.cli.serialization.userfacing.UFStatus) UFWorkspace(bio.terra.cli.serialization.userfacing.UFWorkspace) Matchers.emptyString(org.hamcrest.Matchers.emptyString) Matchers.containsString(org.hamcrest.Matchers.containsString) TestUser(harness.TestUser) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with UFWorkspaceLight

use of bio.terra.cli.serialization.userfacing.UFWorkspaceLight in project terra-cli by DataBiosphere.

the class Workspace method statusDescribeListReflectCreate.

@Test
@DisplayName("status, describe, workspace list reflect workspace create")
void statusDescribeListReflectCreate() throws IOException {
    // select a test user and login
    TestUser testUser = TestUser.chooseTestUserWithSpendAccess();
    testUser.login();
    // `terra workspace create --format=json`
    UFWorkspace createWorkspace = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "create");
    // check the created workspace has an id and a google project
    assertNotNull(createWorkspace.id, "create workspace returned a workspace id");
    assertNotNull(createWorkspace.googleProjectId, "create workspace created a gcp project");
    assertThat("workspace email matches test user", createWorkspace.userEmail, equalToIgnoringCase(testUser.email));
    // `terra status --format=json`
    UFStatus status = TestCommand.runAndParseCommandExpectSuccess(UFStatus.class, "status");
    // check the current status reflects the new workspace
    assertThat("workspace server matches current server", createWorkspace.serverName, equalToIgnoringCase(status.server.name));
    assertEquals(createWorkspace.id, status.workspace.id, "workspace id matches current status");
    assertEquals(createWorkspace.googleProjectId, status.workspace.googleProjectId, "workspace gcp project matches current status");
    // `terra workspace describe --format=json`
    UFWorkspace describeWorkspace = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "describe");
    // check the new workspace is returned by describe
    assertEquals(createWorkspace.id, describeWorkspace.id, "workspace id matches that in describe");
    assertEquals(createWorkspace.googleProjectId, describeWorkspace.googleProjectId, "workspace gcp project matches that in describe");
    // check the new workspace is included in the list
    List<UFWorkspaceLight> matchingWorkspaces = listWorkspacesWithId(createWorkspace.id);
    assertEquals(1, matchingWorkspaces.size(), "new workspace is included exactly once in list");
    assertEquals(createWorkspace.id, matchingWorkspaces.get(0).id, "workspace id matches that in list");
    assertEquals(createWorkspace.googleProjectId, matchingWorkspaces.get(0).googleProjectId, "workspace gcp project matches that in list");
    // `terra workspace delete`
    TestCommand.runCommandExpectSuccess("workspace", "delete", "--quiet");
}
Also used : UFWorkspaceLight(bio.terra.cli.serialization.userfacing.UFWorkspaceLight) UFStatus(bio.terra.cli.serialization.userfacing.UFStatus) UFWorkspace(bio.terra.cli.serialization.userfacing.UFWorkspace) TestUser(harness.TestUser) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with UFWorkspaceLight

use of bio.terra.cli.serialization.userfacing.UFWorkspaceLight in project terra-cli by DataBiosphere.

the class Workspace method statusDescribeListReflectDelete.

@Test
@DisplayName("status, describe, workspace list reflect workspace delete")
void statusDescribeListReflectDelete() throws IOException {
    // select a test user and login
    TestUser testUser = TestUser.chooseTestUserWithSpendAccess();
    testUser.login();
    // `terra workspace create --format=json`
    UFWorkspace createWorkspace = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "create");
    // `terra workspace delete --format=json`
    TestCommand.runCommandExpectSuccess("workspace", "delete", "--quiet");
    // `terra status --format=json`
    UFStatus status = TestCommand.runAndParseCommandExpectSuccess(UFStatus.class, "status");
    // check the current status reflects the deleted workspace
    assertNull(status.workspace, "status has no workspace after delete");
    // `terra workspace describe --format=json`
    TestCommand.runCommandExpectExitCode(1, "workspace", "describe");
    // check the deleted workspace is not included in the list
    List<UFWorkspaceLight> matchingWorkspaces = listWorkspacesWithId(createWorkspace.id);
    assertEquals(0, matchingWorkspaces.size(), "deleted workspace is not included in list");
}
Also used : UFWorkspaceLight(bio.terra.cli.serialization.userfacing.UFWorkspaceLight) UFStatus(bio.terra.cli.serialization.userfacing.UFStatus) UFWorkspace(bio.terra.cli.serialization.userfacing.UFWorkspace) TestUser(harness.TestUser) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

UFWorkspace (bio.terra.cli.serialization.userfacing.UFWorkspace)4 UFWorkspaceLight (bio.terra.cli.serialization.userfacing.UFWorkspaceLight)4 DisplayName (org.junit.jupiter.api.DisplayName)4 Test (org.junit.jupiter.api.Test)4 UFStatus (bio.terra.cli.serialization.userfacing.UFStatus)3 TestUser (harness.TestUser)3 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Matchers.emptyString (org.hamcrest.Matchers.emptyString)1