Search in sources :

Example 1 with UFGitRepo

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

the class GitRepoReferenced method listDescribeReflectAdd.

@Test
@DisplayName("list and describe reflect adding a new referenced git repo")
void listDescribeReflectAdd() throws IOException {
    workspaceCreator.login();
    // `terra workspace set --id=$id`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + getWorkspaceId());
    // `terra resource add-ref git-repo --name=$name --repo-url=$repoUrl
    String name = "listDescribeReflectAdd";
    UFGitRepo addedGitRepositoryReference = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "add-ref", "git-repo", "--name=" + name, "--repo-url=" + GIT_REPO_HTTPS_URL);
    // check that the name and git repo name match
    assertEquals(name, addedGitRepositoryReference.name, "add ref output matches name");
    assertEquals(GIT_REPO_HTTPS_URL, addedGitRepositoryReference.gitRepoUrl, "add ref output matches git repo url");
    // check that the git repo is in the list
    List<UFGitRepo> matchedResourceList = listGitRepoResourcesWithName(name);
    assertEquals(1, matchedResourceList.size());
    UFGitRepo matchedResource = matchedResourceList.get(0);
    assertEquals(name, matchedResource.name, "list output matches name");
    assertEquals(GIT_REPO_HTTPS_URL, matchedResource.gitRepoUrl, "list output matches git repo url");
    // `terra resource describe --name=$name --format=json`
    UFGitRepo describeResource = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "describe", "--name=" + name);
    // check that the name and the git repo url match
    assertEquals(name, describeResource.name, "describe resource output matches name");
    assertEquals(GIT_REPO_HTTPS_URL, describeResource.gitRepoUrl, "describe resource output matches git repo url");
    // `terra resource delete --name=$name`
    TestCommand.runCommandExpectSuccess("resource", "delete", "--name=" + name, "--quiet");
}
Also used : UFGitRepo(bio.terra.cli.serialization.userfacing.resource.UFGitRepo) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with UFGitRepo

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

the class GitRepoReferenced method updateMultipleOrNoProperties.

@Test
@DisplayName("update a referenced git repo, specifying multiple or none of the properties")
void updateMultipleOrNoProperties() throws IOException {
    workspaceCreator.login();
    // `terra workspace set --id=$id`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + getWorkspaceId());
    // `terra resources add-ref git-repo --name=$name --description=$description
    // --repo-url=$gitUrl
    String name = "updateMultipleOrNoProperties";
    String description = "updateDescription";
    TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "add-ref", "git-repo", "--name=" + name, "--description=" + description, "--repo-url=" + GIT_REPO_SSH_URL);
    // call update without specifying any properties to modify
    // `terra resources update git-repo --name=$name`
    String stdErr = TestCommand.runCommandExpectExitCode(1, "resource", "update", "git-repo", "--name=" + name);
    assertThat("Specify at least one property to update..", stdErr, CoreMatchers.containsString("Specify at least one property to update."));
    // update the name and description
    // `terra resources update gcs-object --name=$name --new-name=$newName
    // --description=$newDescription`
    String newName = "updateMultipleOrNoProperties_NEW";
    String newDescription = "updateDescription_NEW";
    UFGitRepo updateGitRepoNameAndDescription = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "update", "git-repo", "--name=" + name, "--new-name=" + newName, "--description=" + newDescription);
    assertEquals(newName, updateGitRepoNameAndDescription.name);
    assertEquals(newDescription, updateGitRepoNameAndDescription.description);
    // `terra resources describe --name=$newName2`
    UFGitRepo describeGitRepo = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "describe", "--name=" + newName);
    assertEquals(newDescription, describeGitRepo.description);
    // update referencing target
    // `terra resources update git-repo --name=$name --new-repo-url=$newRepoUrl
    // --new-name=$newName --description=$newDescription
    String yetAnotherName = "updateMultipleOrNoProperties_NEW";
    String yetAnotherDescription = "updateDescription_NEW";
    UFGitRepo updateGitRepoReferenceTarget = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "update", "git-repo", "--name=" + newName, "--new-name=" + yetAnotherName, "--description=" + yetAnotherDescription, "--new-repo-url=" + GIT_REPO_HTTPS_URL);
    assertEquals(GIT_REPO_HTTPS_URL, updateGitRepoReferenceTarget.gitRepoUrl);
    UFGitRepo describeGitRepoAfterUpdatingReferenceTarget = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "describe", "--name=" + yetAnotherName);
    assertEquals(yetAnotherDescription, describeGitRepoAfterUpdatingReferenceTarget.description);
    assertEquals(GIT_REPO_HTTPS_URL, describeGitRepoAfterUpdatingReferenceTarget.gitRepoUrl);
    assertEquals(yetAnotherName, describeGitRepoAfterUpdatingReferenceTarget.name);
}
Also used : UFGitRepo(bio.terra.cli.serialization.userfacing.resource.UFGitRepo) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with UFGitRepo

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

the class GitRepo method execute.

/**
 * Add a referenced git repo to the workspace.
 */
@Override
protected void execute() {
    workspaceOption.overrideIfSpecified();
    // build the resource object to add
    CreateResourceParams.Builder createResourceParams = resourceCreationOptions.populateMetadataFields().stewardshipType(StewardshipType.REFERENCED);
    AddGitRepoParams.Builder createParams = new AddGitRepoParams.Builder().resourceFields(createResourceParams.build()).gitRepoUrl(repoUrl);
    bio.terra.cli.businessobject.resource.GitRepo addedResource = bio.terra.cli.businessobject.resource.GitRepo.addReferenced(createParams.build());
    formatOption.printReturnValue(new UFGitRepo(addedResource), GitRepo::printText);
}
Also used : UFGitRepo(bio.terra.cli.serialization.userfacing.resource.UFGitRepo) CreateResourceParams(bio.terra.cli.serialization.userfacing.input.CreateResourceParams) UFGitRepo(bio.terra.cli.serialization.userfacing.resource.UFGitRepo) AddGitRepoParams(bio.terra.cli.serialization.userfacing.input.AddGitRepoParams) WorkspaceOverride(bio.terra.cli.command.shared.options.WorkspaceOverride)

Example 4 with UFGitRepo

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

the class GitRepoReferenced method addWithAllOptions.

@Test
@DisplayName("add a referenced git repo, specifying all options")
void addWithAllOptions() throws IOException {
    workspaceCreator.login();
    // `terra workspace set --id=$id`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + getWorkspaceId());
    // `terra resources add-ref git-repo --name=$name --repo-url=$repoUrl
    // --cloning=$cloning --description=$description --format=json`
    String name = "addWithAllOptions";
    CloningInstructionsEnum cloning = CloningInstructionsEnum.REFERENCE;
    String description = "add with all options";
    UFGitRepo gitRepoReference = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "add-ref", "git-repo", "--name=" + name, "--description=" + description, "--cloning=" + cloning, "--repo-url=" + GIT_REPO_SSH_URL);
    // check that the properties match
    assertEquals(name, gitRepoReference.name, "add ref output matches name");
    assertEquals(GIT_REPO_SSH_URL, gitRepoReference.gitRepoUrl, "add ref output matches git repo url");
    assertEquals(cloning, gitRepoReference.cloningInstructions, "add ref output matches cloning");
    assertEquals(description, gitRepoReference.description, "add ref output matches description");
    // `terra resources describe --name=$name --format=json`
    UFGitRepo describeResource = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "describe", "--name=" + name);
    // check that the properties match
    assertEquals(name, describeResource.name, "describe resource output matches name");
    assertEquals(GIT_REPO_SSH_URL, describeResource.gitRepoUrl, "describe resource output matches git repo url");
    assertEquals(cloning, describeResource.cloningInstructions, "describe output matches cloning");
    assertEquals(description, describeResource.description, "describe output matches description");
    // `terra resources delete --name=$name`
    TestCommand.runCommandExpectSuccess("resource", "delete", "--name=" + name, "--quiet");
}
Also used : CloningInstructionsEnum(bio.terra.workspace.model.CloningInstructionsEnum) UFGitRepo(bio.terra.cli.serialization.userfacing.resource.UFGitRepo) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with UFGitRepo

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

the class GitRepoReferenced method updateIndividualProperties.

@Test
@DisplayName("update a referenced git repo, one property at a time")
void updateIndividualProperties() throws IOException {
    workspaceCreator.login();
    // `terra workspace set --id=$id`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + getWorkspaceId());
    // `terra resource add-ref git-repo --name=$name --repo-url=$repoUrl --description=$description`
    String name = "updateIndividualProperties";
    String description = "updateDescription";
    TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "add-ref", "git-repo", "--name=" + name, "--description=" + description, "--repo-url=" + GIT_REPO_SSH_URL);
    // update just the name
    // `terra resources update git-repo --name=$name --new-name=$newName`
    String newName = "updateIndividualProperties_NEW";
    UFGitRepo updateGitRepo = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "update", "git-repo", "--name=" + name, "--new-name=" + newName);
    assertEquals(newName, updateGitRepo.name);
    assertEquals(description, updateGitRepo.description);
    // `terra resources describe --name=$newName`
    UFGitRepo describeGitRepo = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "describe", "--name=" + newName);
    assertEquals(description, describeGitRepo.description);
    // update just the description
    // `terra resources update git-repo --name=$newName --description=$newDescription`
    String newDescription = "updateDescription_NEW";
    updateGitRepo = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "update", "git-repo", "--name=" + newName, "--description=" + newDescription);
    assertEquals(newName, updateGitRepo.name);
    assertEquals(newDescription, updateGitRepo.description);
    // `terra resources describe --name=$newName`
    describeGitRepo = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "describe", "--name=" + newName);
    assertEquals(newDescription, describeGitRepo.description);
    updateGitRepo = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "update", "git-repo", "--name=" + newName, "--new-repo-url=" + GIT_REPO_HTTPS_URL);
    assertEquals(GIT_REPO_HTTPS_URL, updateGitRepo.gitRepoUrl);
    String resolved = TestCommand.runAndParseCommandExpectSuccess(String.class, "resource", "resolve", "--name=" + newName);
    assertEquals(GIT_REPO_HTTPS_URL, resolved, "resolve matches https Git url");
}
Also used : UFGitRepo(bio.terra.cli.serialization.userfacing.resource.UFGitRepo) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

UFGitRepo (bio.terra.cli.serialization.userfacing.resource.UFGitRepo)7 Test (org.junit.jupiter.api.Test)5 DisplayName (org.junit.jupiter.api.DisplayName)4 WorkspaceOverride (bio.terra.cli.command.shared.options.WorkspaceOverride)2 UserActionableException (bio.terra.cli.exception.UserActionableException)1 UFClonedResource (bio.terra.cli.serialization.userfacing.UFClonedResource)1 UFClonedWorkspace (bio.terra.cli.serialization.userfacing.UFClonedWorkspace)1 UFResource (bio.terra.cli.serialization.userfacing.UFResource)1 UFWorkspace (bio.terra.cli.serialization.userfacing.UFWorkspace)1 AddGitRepoParams (bio.terra.cli.serialization.userfacing.input.AddGitRepoParams)1 CreateResourceParams (bio.terra.cli.serialization.userfacing.input.CreateResourceParams)1 UpdateReferencedGitRepoParams (bio.terra.cli.serialization.userfacing.input.UpdateReferencedGitRepoParams)1 UFBqDataset (bio.terra.cli.serialization.userfacing.resource.UFBqDataset)1 UFGcsBucket (bio.terra.cli.serialization.userfacing.resource.UFGcsBucket)1 CloningInstructionsEnum (bio.terra.workspace.model.CloningInstructionsEnum)1