use of harness.TestCommand.Result in project terra-cli by DataBiosphere.
the class Config method appLaunch.
@Test
@DisplayName("app-launch config affects how apps are launched")
void appLaunch() throws IOException {
String badImageError = "No such image: badimageid";
workspaceCreator.login();
// `terra workspace set --id=$id`
TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + getWorkspaceId());
// set the docker image id to an invalid string
TestCommand.runCommandExpectSuccess("config", "set", "image", "--image=badimageid");
// `terra config set app-launch LOCAL_PROCESS`
TestCommand.runCommandExpectSuccess("config", "set", "app-launch", "LOCAL_PROCESS");
// apps launched via local process should not be affected
Result cmd = TestCommand.runCommand("app", "execute", "echo", "$GOOGLE_CLOUD_PROJECT");
// cmd exit code can either be 0=success or 1 because gcloud fails with
// `(gcloud.config.get-value) Failed to create the default configuration. Ensure your have the
// correct permissions on`.
assertThat("Expected to return exit code 0 or 1, instead got " + cmd.exitCode, cmd.exitCode == 0 || cmd.exitCode == 1);
assertThat("bad docker image should not affect local mode", cmd.stdErr, not(containsString(badImageError)));
// `terra config set app-launch DOCKER_CONTAINER`
TestCommand.runCommandExpectSuccess("config", "set", "app-launch", "DOCKER_CONTAINER");
// apps launched via docker container should error out
String stdErr = TestCommand.runCommandExpectExitCode(3, "app", "execute", "echo", "$GOOGLE_CLOUD_PROJECT");
assertThat("docker image not found error returned", stdErr, containsString(badImageError));
}
use of harness.TestCommand.Result in project terra-cli by DataBiosphere.
the class Syntax method configOptions.
@Test
@DisplayName("config value enums are accepted in any case")
void configOptions() {
Result resultLowercase = TestCommand.runCommand("config", "set", "browser", "manual");
assertThat(resultLowercase.stdOut, containsString("Browser launch mode for login is MANUAL"));
Result resultUppercase = TestCommand.runCommand("config", "set", "browser", "MANUAL");
assertThat(resultUppercase.stdOut, containsString("Browser launch mode for login is MANUAL"));
Result resultMixed = TestCommand.runCommand("config", "set", "browser", "mAnual");
assertThat(resultMixed.stdOut, containsString("Browser launch mode for login is MANUAL"));
}
use of harness.TestCommand.Result in project terra-cli by DataBiosphere.
the class Syntax method formatOptions.
@Test
@DisplayName("format options are accepted in any case")
void formatOptions() {
Result resultLowercase = TestCommand.runCommand("status", "--format=json");
assertThat(resultLowercase.stdOut, containsString("\"workspace\" :"));
Result resultUppercase = TestCommand.runCommand("status", "--format=JSON");
assertThat(resultUppercase.stdOut, containsString("\"workspace\" :"));
Result resultMixed = TestCommand.runCommand("status", "--format=jSON");
assertThat(resultMixed.stdOut, containsString("\"workspace\" :"));
}
use of harness.TestCommand.Result in project terra-cli by DataBiosphere.
the class Workspace method describeReflectsNumResources.
@Test
@DisplayName("workspace describe reflects the number of resources")
void describeReflectsNumResources() throws IOException {
// select a test user and login
TestUser testUser = TestUser.chooseTestUserWithSpendAccess();
testUser.login();
// `terra workspace create`
UFWorkspace createdWorkspace = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "create");
assertEquals(0, createdWorkspace.numResources, "new workspace has 0 resources");
// `terra resource create gcs-bucket --name=$name --bucket-name=$bucketName`
String bucketResourceName = "describeReflectsNumResourcesGCS";
String bucketName = UUID.randomUUID().toString();
TestCommand.runCommandExpectSuccess("resource", "create", "gcs-bucket", "--name=" + bucketResourceName, "--bucket-name=" + bucketName);
// `terra workspace describe`
UFWorkspace describeWorkspace = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "describe");
assertEquals(1, describeWorkspace.numResources, "worksapce has 1 resource after creating bucket");
// `terra resource create bq-dataset --name=$name --dataset-id=$datasetId`
String datasetResourceName = "describeReflectsNumResourcesBQ";
String datasetId = "bq1";
TestCommand.runCommandExpectSuccess("resource", "create", "bq-dataset", "--name=" + datasetResourceName, "--dataset-id=" + datasetId);
// `terra workspace describe`
Result describeResult2 = TestCommand.runCommand("workspace", "describe");
assertEquals(0, describeResult2.exitCode, "Describe was successful.");
assertThat("workspace has 2 resources after creating dataset", describeResult2.stdOut, containsString("# Resources: 2"));
assertThat("No error message is displayed on second describe.", describeResult2.stdErr, is(emptyString()));
UFWorkspace describeWorkspace3 = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "describe");
assertEquals(2, describeWorkspace3.numResources, "worksapce has 2 resources after creating dataset");
// `terra workspace delete`
TestCommand.runCommandExpectSuccess("workspace", "delete", "--quiet");
}
use of harness.TestCommand.Result in project terra-cli by DataBiosphere.
the class Config method format.
@Test
@DisplayName("config format determines default output format")
void format() throws JsonProcessingException {
// Note: we can't use runAndParseCommandExpectSuccess() here, since it sets the format
// to JSON internally.
TestCommand.runCommandExpectSuccess("config", "set", "format", "json");
// if this works, the format was valid json
Result result1 = TestCommand.runCommand("config", "list");
assertThat(result1.stdOut, containsString("\"format\" : \"JSON\""));
TestCommand.runCommand("config", "set", "format", "text");
Result result2 = TestCommand.runCommand("config", "list");
assertThat(result2.stdOut, containsString("[format] output format = TEXT"));
// --format switch overrides current setting
Result result3 = TestCommand.runCommand("config", "list", "--format=json");
assertThat(result3.stdOut, containsString("\"format\" : \"TEXT\""));
}
Aggregations