Search in sources :

Example 6 with P4TestRepo

use of com.thoughtworks.go.helper.P4TestRepo in project gocd by gocd.

the class P4MaterialTestBase method shouldCleanOutRepoWhenMaterialChanges.

@Test
public void shouldCleanOutRepoWhenMaterialChanges() throws Exception {
    P4TestRepo secondTestRepo = P4TestRepo.createP4TestRepo(temporaryFolder, clientFolder);
    try {
        secondTestRepo.onSetup();
        P4Material p4Material = p4Fixture.material(VIEW);
        updateMaterial(p4Material, new StringRevision("2"));
        File.createTempFile("temp", "txt", clientFolder);
        assertThat(clientFolder.listFiles().length, is(9));
        P4Material otherMaterial = secondTestRepo.material("//depot/lib/... //something/...");
        otherMaterial.setUsername("cceuser1");
        updateMaterial(otherMaterial, new StringRevision("2"));
        File.createTempFile("temp", "txt", clientFolder);
        assertThat("Should clean and re-checkout after p4repo changed", clientFolder.listFiles().length, is(3));
        otherMaterial.setUsername("cceuser");
        otherMaterial.setPassword("password");
        updateMaterial(otherMaterial, new StringRevision("2"));
        assertThat("Should clean and re-checkout after user changed", clientFolder.listFiles().length, is(2));
        assertThat(outputconsumer.getStdOut(), containsString("Working directory has changed. Deleting and re-creating it."));
    } finally {
        secondTestRepo.stop();
        secondTestRepo.onTearDown();
    }
}
Also used : P4TestRepo(com.thoughtworks.go.helper.P4TestRepo) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) Test(org.junit.Test)

Aggregations

P4TestRepo (com.thoughtworks.go.helper.P4TestRepo)6 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)1 Test (org.junit.Test)1