Skip to content

Commit

Permalink
further fix for the windows failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
verhas committed Oct 29, 2024
1 parent ca32950 commit b206984
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
5 changes: 2 additions & 3 deletions jamal-git/src/test/java/javax0/jamal/git/GitTestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ public class GitTestHelper {
private Git git;
private File repoDir;


public File getRepoDir() {
return repoDir;
String getRepoDir() {
return repoDir.getAbsolutePath().replaceAll("\\\\","/");
}

/**
Expand Down
20 changes: 7 additions & 13 deletions jamal-git/src/test/java/javax0/jamal/git/TestCommit.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@

public class TestCommit {

private File repoDir;
private GitTestHelper helper;

@BeforeEach
public void setup() throws Exception {
helper = new GitTestHelper();
helper.setup();
repoDir = helper.getRepoDir();
}

@AfterEach
Expand All @@ -32,55 +30,51 @@ public void latestCommit() throws Exception {
final var result = new String[]{"[0-9a-f]{40}", "Pinco Palino", "\\d+", "\\d+", "Rev: chicken was added", "Rev: chicken was added", "[0-9a-f]{7}", "Peter Muster", "[0-9a-f]{40}", "[0-9a-f]{40}",};
for (int i = 0; i < what.length; i++) {
final int j = i;
final var theInput = "{@git location=\"" + getRepoDir() + "\"}{@git:commit branch=main last " + what[j] + "}";
final var theInput = "{@git location=\"" + helper.getRepoDir() + "\"}{@git:commit branch=main last " + what[j] + "}";
TestThat.theInput(theInput)
.results(s -> s.matches(result[j]), r-> String.format("For the %s expected: %s, got: %s", theInput,result[j], r));
}
}

private String getRepoDir() {
return repoDir.getAbsolutePath().replaceAll("\\\\","/");
}

@Test
@DisplayName("Get the footnote from the latest commit")
public void latestCommiFootnote() throws Exception {
TestThat.theInput("{@git location=\"" + getRepoDir() + "\"}{@git:commit branch=main last footnote=rev}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:commit branch=main last footnote=rev}")
.results("chicken was added\n");
}

@Test
@DisplayName("Get the latest commit message")
public void latestCommitMessage() throws Exception {
TestThat.theInput("{@git location=\"" + getRepoDir() + "\"}{@git:commit branch=main last message}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:commit branch=main last message}")
.results("Rev: chicken was added");
}

@Test
@DisplayName("Get the last but one commit message")
public void lastButOneCommitMessage() throws Exception {
TestThat.theInput("{@git location=\"" + getRepoDir() + "\"}{@git:commit branch=main index=1 message}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:commit branch=main index=1 message}")
.results("Rev: chucken _\nwas added");
}

@Test
@DisplayName("Get the last but one commit footnote")
public void lastButOneCommitFootnote() throws Exception {
TestThat.theInput("{@git location=\"" + getRepoDir() + "\"}{@git:commit branch=main index=1 footnote=rev}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:commit branch=main index=1 footnote=rev}")
.results("chucken\nwas added\n");
}

@Test
@DisplayName("Get all commit hashes")
public void allCommitHashes() throws Exception {
TestThat.theInput("{@git location=\"" + getRepoDir() + "\"}{@git:commits branch=main hash}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:commits branch=main hash}")
.results(s -> s.matches("(?:[0-9a-f]{40},)*[0-9a-f]{40}"));
}

@Test
@DisplayName("Get limited commit hashes")
public void limitedCommitHashes() throws Exception {
TestThat.theInput("{@git location=\"" + getRepoDir() + "\"}{@git:commits branch=main hash limit=1}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:commits branch=main hash limit=1}")
.results(s -> s.matches("[0-9a-f]{40}"));
}

Expand Down
25 changes: 11 additions & 14 deletions jamal-git/src/test/java/javax0/jamal/git/TestTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@

public class TestTag {

private File repoDir;

private GitTestHelper helper;

@BeforeEach
public void setup() throws Exception {
helper = new GitTestHelper();
helper.setup();
repoDir = helper.getRepoDir();
}

@AfterEach
Expand All @@ -26,78 +23,78 @@ public void tearDown() throws Exception {
@Test
@DisplayName("Get all the tags")
public void allTags() throws Exception {
TestThat.theInput("{@git location=\"" + repoDir.getAbsolutePath() + "\"}{@git:tags orderByDate}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:tags orderByDate}")
.results("v1.0,v2.0,3.0");
}

@Test
@DisplayName("Get all the tags starting with V")
public void allTagsV() throws Exception {
TestThat.theInput("{@git location=\"" + repoDir.getAbsolutePath() + "\"}{@git:tags orderByDate match=\"v.*\"}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:tags orderByDate match=\"v.*\"}")
.results("v1.0,v2.0");
}

@Test
@DisplayName("Get all the tags starting with V special separator")
public void allTagsVSep() throws Exception {
TestThat.theInput("{@git location=\"" + repoDir.getAbsolutePath() + "\"}{@git:tags orderByDate match=\"v.*\" sep=:}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:tags orderByDate match=\"v.*\" sep=:}")
.results("v1.0:v2.0");
}

@Test
@DisplayName("Get the latest tag")
public void latestTag() throws Exception {
TestThat.theInput("{@git location=\"" + repoDir.getAbsolutePath() + "\"}{@git:tags last orderByDate}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:tags last orderByDate}")
.results("3.0");
}

@Test
@DisplayName("Get the last tag by name")
public void lastTag() throws Exception {
TestThat.theInput("{@git location=\"" + repoDir.getAbsolutePath() + "\"}{@git:tags last orderByName}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:tags last orderByName}")
.results("v2.0");
}

@Test
@DisplayName("Get the last tag by name time")
public void lastTagtime() throws Exception {
TestThat.theInput("{@git location=\"" + repoDir.getAbsolutePath() + "\"}{@git:tags last orderByName time}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:tags last orderByName time}")
.results("20");
}

@Test
@DisplayName("Get the last tag by name hashCode")
public void lastTagHash() throws Exception {
TestThat.theInput("{@git location=\"" + repoDir.getAbsolutePath() + "\"}{@git:tags last orderByName hash}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:tags last orderByName hash}")
.results(s -> s.matches("[0-9a-f]{40}"));
}


@Test
@DisplayName("Get all the branchs")
public void allBranches() throws Exception {
TestThat.theInput("{@git location=\"" + repoDir.getAbsolutePath() + "\"}{@git:branches orderByName}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:branches orderByName}")
.results("branch1,branch2,branch3,branch4,branch5,main,release");
}

@Test
@DisplayName("Get the last branch by name")
public void lastBranch() throws Exception {
TestThat.theInput("{@git location=\"" + repoDir.getAbsolutePath() + "\"}{@git:branches last orderByName}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:branches last orderByName}")
.results("release");
}

@Test
@DisplayName("Get the last branch by name time")
public void lastBranchtime() throws Exception {
TestThat.theInput("{@git location=\"" + repoDir.getAbsolutePath() + "\"}{@git:branches last orderByName time}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:branches last orderByName time}")
.results(s -> s.matches("\\d+"));
}

@Test
@DisplayName("Get the last branch by name hashCode")
public void lastBranchHash() throws Exception {
TestThat.theInput("{@git location=\"" + repoDir.getAbsolutePath() + "\"}{@git:branches last orderByName hash}")
TestThat.theInput("{@git location=\"" + helper.getRepoDir() + "\"}{@git:branches last orderByName hash}")
.results(s -> s.matches("[0-9a-f]{40}"));
}

Expand Down

0 comments on commit b206984

Please sign in to comment.