Skip to content

Commit

Permalink
test update, ENoVersionFile is thrown if version file is missing in d…
Browse files Browse the repository at this point in the history
…evelop branch
  • Loading branch information
host6 committed Jan 5, 2018
1 parent 935683d commit d643a38
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/scm4j/releaser/branch/DevelopBranch.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.scm4j.releaser.Utils;
import org.scm4j.releaser.conf.Component;
import org.scm4j.releaser.conf.VCSRepository;
import org.scm4j.releaser.exceptions.EComponentConfigNoUrl;
import org.scm4j.releaser.exceptions.ENoVersionFile;
import org.scm4j.vcs.api.VCSCommit;
import org.scm4j.vcs.api.exceptions.EVCSFileNotFound;

Expand Down Expand Up @@ -35,7 +35,7 @@ public Version getVersion() {
String verFileContent = repo.getVCS().getFileContent(repo.getDevelopBranch(), Utils.VER_FILE_NAME, null);
return new Version(verFileContent.trim());
} catch (EVCSFileNotFound e) {
throw new EComponentConfigNoUrl(Utils.VER_FILE_NAME + " file is missing in develop branch of " + comp);
throw new ENoVersionFile(comp);
}
}
}
11 changes: 11 additions & 0 deletions src/main/java/org/scm4j/releaser/exceptions/ENoVersionFile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.scm4j.releaser.exceptions;

import org.scm4j.releaser.Utils;
import org.scm4j.releaser.conf.Component;

public class ENoVersionFile extends EReleaserException {

public ENoVersionFile(Component comp) {
super(Utils.VER_FILE_NAME + " file is missing in develop branch of " + comp);
}
}
12 changes: 6 additions & 6 deletions src/test/java/org/scm4j/releaser/branch/DevelopBranchTest.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package org.scm4j.releaser.branch;

import org.junit.Test;
import org.scm4j.releaser.testutils.TestEnvironment;
import org.scm4j.releaser.Utils;
import org.scm4j.releaser.conf.Component;
import org.scm4j.releaser.conf.VCSRepository;
import org.scm4j.releaser.exceptions.EComponentConfigNoUrl;
import org.scm4j.releaser.exceptions.ENoVersionFile;
import org.scm4j.releaser.testutils.TestEnvironment;
import org.scm4j.vcs.api.IVCS;

import java.util.ArrayList;

import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;

public class DevelopBranchTest {

Expand All @@ -32,7 +33,7 @@ public void testIsNotModifiedIfNoCommits() throws Exception {
}

@Test
public void testGetVersionIfNoVersionFile() throws Exception {
public void testNoVersionFileExcetpion() throws Exception {
try (TestEnvironment env = new TestEnvironment()) {
env.generateTestEnvironment();
Component comp = new Component(TestEnvironment.PRODUCT_UNTILL);
Expand All @@ -42,8 +43,7 @@ public void testGetVersionIfNoVersionFile() throws Exception {
try {
db.getVersion();
fail();
} catch (EComponentConfigNoUrl e) {

} catch (ENoVersionFile e) {
}
}
}
Expand Down

0 comments on commit d643a38

Please sign in to comment.