Search in sources :

Example 6 with Commit

use of com.google.startupos.common.repo.Protos.Commit in project startup-os by google.

the class CodeReviewServiceGetDiffFilesTest method testGetDiffFiles_whenFileIsModifiedAndNewFileIsAdded.

@Test
public void testGetDiffFiles_whenFileIsModifiedAndNewFileIsAdded() {
    writeFile("new_file_content");
    writeFile("new_file.txt", "file content");
    final String lastCommitId = repo.commit(repo.getUncommittedFiles(), COMMIT_MESSAGE).getId();
    Commit lastCommit = Commit.newBuilder().setId(lastCommitId).addFile(File.newBuilder().setFilename("new_file.txt").setWorkspace("ws1").setRepoId(REPO_ID).setCommitId(lastCommitId).setFilenameWithRepo("startup-os/new_file.txt").build()).addFile(File.newBuilder().setFilename("test_file.txt").setWorkspace("ws1").setRepoId(REPO_ID).setCommitId(lastCommitId).setAction(File.Action.MODIFY).setFilenameWithRepo("startup-os/test_file.txt").build()).build();
    assertEquals(getExpectedResponseAddingCommit(lastCommit), getResponse());
}
Also used : Commit(com.google.startupos.common.repo.Protos.Commit) Test(org.junit.Test)

Example 7 with Commit

use of com.google.startupos.common.repo.Protos.Commit in project startup-os by google.

the class CodeReviewServiceGetDiffFilesTest method testGetDiffFiles_whenNewFileIsAdded.

@Test
public void testGetDiffFiles_whenNewFileIsAdded() {
    writeFile("new_file.txt", "file content");
    final String lastCommitId = repo.commit(repo.getUncommittedFiles(), COMMIT_MESSAGE).getId();
    Commit lastCommit = Commit.newBuilder().setId(lastCommitId).addFile(File.newBuilder().setFilename("new_file.txt").setWorkspace("ws1").setRepoId(REPO_ID).setCommitId(lastCommitId).setFilenameWithRepo("startup-os/new_file.txt").build()).build();
    assertEquals(getExpectedResponseAddingCommit(lastCommit), getResponse());
}
Also used : Commit(com.google.startupos.common.repo.Protos.Commit) Test(org.junit.Test)

Example 8 with Commit

use of com.google.startupos.common.repo.Protos.Commit in project startup-os by google.

the class CodeReviewServiceGetDiffFilesTest method testGetDiffFiles_whenFileIsDeletedAndNewFileIsAdded.

@Test
public void testGetDiffFiles_whenFileIsDeletedAndNewFileIsAdded() throws IOException {
    writeFile("new_file.txt", "file content");
    fileUtils.deleteFileOrDirectoryIfExists(fileUtils.joinPaths(getWorkspaceFolder(TEST_WORKSPACE), "startup-os", TEST_FILE));
    final String lastCommitId = repo.commit(repo.getUncommittedFiles(), COMMIT_MESSAGE).getId();
    Commit lastCommit = Commit.newBuilder().setId(lastCommitId).addFile(File.newBuilder().setFilename("new_file.txt").setWorkspace("ws1").setRepoId(REPO_ID).setCommitId(lastCommitId).setFilenameWithRepo("startup-os/new_file.txt").build()).addFile(File.newBuilder().setFilename("test_file.txt").setWorkspace("ws1").setRepoId(REPO_ID).setCommitId(lastCommitId).setAction(File.Action.DELETE).setFilenameWithRepo("startup-os/test_file.txt").build()).build();
    assertEquals(getExpectedResponseAddingCommit(lastCommit), getResponse());
}
Also used : Commit(com.google.startupos.common.repo.Protos.Commit) Test(org.junit.Test)

Example 9 with Commit

use of com.google.startupos.common.repo.Protos.Commit in project startup-os by google.

the class CodeReviewServiceGetDiffFilesTest method testGetDiffFiles_whenNewFileIsDeleted.

@Test
public void testGetDiffFiles_whenNewFileIsDeleted() throws IOException {
    fileUtils.deleteFileOrDirectoryIfExists(fileUtils.joinPaths(getWorkspaceFolder(TEST_WORKSPACE), "startup-os", TEST_FILE));
    final String lastCommitId = repo.commit(repo.getUncommittedFiles(), COMMIT_MESSAGE).getId();
    Commit lastCommit = Commit.newBuilder().setId(lastCommitId).addFile(File.newBuilder().setFilename("test_file.txt").setWorkspace("ws1").setRepoId(REPO_ID).setCommitId(lastCommitId).setAction(File.Action.DELETE).setFilenameWithRepo("startup-os/test_file.txt").build()).build();
    assertEquals(getExpectedResponseAddingCommit(lastCommit), getResponse());
}
Also used : Commit(com.google.startupos.common.repo.Protos.Commit) Test(org.junit.Test)

Aggregations

Commit (com.google.startupos.common.repo.Protos.Commit)9 Test (org.junit.Test)5 File (com.google.startupos.common.repo.Protos.File)4 Repo (com.google.startupos.common.repo.Repo)2 ImmutableList (com.google.common.collect.ImmutableList)1 DiffFilesResponse (com.google.startupos.tools.reviewer.local_server.service.Protos.DiffFilesResponse)1 IOException (java.io.IOException)1