Skip to content

Commit

Permalink
feat(#1682): Add more tests for CommentsTagTest
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed May 10, 2023
1 parent c54ae12 commit 0fb7ddd
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions src/test/java/com/rultor/agents/github/CommentsTagTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void duplicatesRelease() throws Exception {
@Test
public void createsReleaseMessage() throws Exception {
final Repo repo = new MkGithub().randomRepo();
final Issue issue = repo.issues().create("Issue title", "");
final Issue issue = repo.issues().create("", "");
final Agent agent = new CommentsTag(repo.github());
final String tag = "v1.5";
final Talk talk = CommentsTagTest.talk(issue, tag);
Expand All @@ -117,9 +117,50 @@ public void createsReleaseMessage() throws Exception {
)
)
);
MatcherAssert.assertThat(smart.name(), Matchers.equalTo("Issue title"));
}

/**
* CommentsTag can create a proper release title.
* @throws Exception In case of error.
*/
@Test
public void createsReleaseTitleFromIssue() throws Exception {
final Repo repo = new MkGithub().randomRepo();
final Issue issue = repo.issues().create("Issue title", "");
final Agent agent = new CommentsTag(repo.github());
final String tag = "v1.6";
agent.execute(CommentsTagTest.talk(issue, tag));
MatcherAssert.assertThat(
new Release.Smart(new Releases.Smart(repo.releases()).find(tag)).name(),
Matchers.equalTo("Issue title")
);
}

/**
* CommentsTag can create a proper release title.
* @throws Exception In case of error.
*/
@Test
public void createsReleaseTitleFromTalk() throws Exception {
final Repo repo = new MkGithub().randomRepo();
final Issue issue = repo.issues().create("Title from issue", "");
final Agent agent = new CommentsTag(repo.github());
final String tag = "v1.7";
final Talk talk = CommentsTagTest.talk(issue, tag);
final String title = "Custom Title";
talk.modify(
new Directives().xpath("/talk/request/args")
.add("arg")
.attr("name", "title")
.set(title));
agent.execute(talk);
MatcherAssert.assertThat(
new Release.Smart(new Releases.Smart(repo.releases()).find(tag)).name(),
Matchers.equalTo(title)
);
}


/**
* Make a talk with this tag.
* @param issue The issue
Expand All @@ -143,9 +184,9 @@ private static Talk talk(final Issue issue, final String tag)
.add("author").set("yegor256").up()
.add("type").set("release").up()
.add("success").set("true").up()
.add("args").add("arg").attr("name", "tag").set(tag)
.add("args")
.add("arg").attr("name", "tag").set(tag).up()
);
return talk;
}

}

0 comments on commit 0fb7ddd

Please sign in to comment.