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");
}
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);
}
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);
}
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");
}
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");
}
Aggregations