Skip to content

Commit ecf921c

Browse files
jibedoublevegep13
authored andcommitted
(#454) Create test
1 parent cea2a43 commit ecf921c

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/GitReleaseManager.Core.Tests/VcsServiceTests.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,45 @@ await _vcsProvider.Received(1).CreateReleaseAsync(OWNER, REPOSITORY, Arg.Is<Rele
321321
_logger.Received(1).Debug(Arg.Any<string>(), Arg.Any<Release>());
322322
}
323323

324+
[Test]
325+
public async Task Should_Create_Release_From_Milestone_With_Assets()
326+
{
327+
var release = new Release { Assets = new List<ReleaseAsset>() };
328+
329+
var assetsCount = _assets.Count;
330+
331+
_releaseNotesBuilder.BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME)
332+
.Returns(Task.FromResult(RELEASE_NOTES));
333+
334+
_vcsProvider.GetReleaseAsync(OWNER, REPOSITORY, MILESTONE_TITLE)
335+
.Returns(Task.FromResult<Release>(null));
336+
337+
_vcsProvider.CreateReleaseAsync(OWNER, REPOSITORY, Arg.Any<Release>())
338+
.Returns(Task.FromResult(release));
339+
340+
var result = await _vcsService.CreateReleaseFromMilestoneAsync(
341+
OWNER,
342+
REPOSITORY,
343+
MILESTONE_TITLE,
344+
MILESTONE_TITLE,
345+
null,
346+
_assets,
347+
false,
348+
null
349+
).ConfigureAwait(false);
350+
result.ShouldBeSameAs(release);
351+
352+
await _releaseNotesBuilder.Received(1).BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME).ConfigureAwait(false);
353+
await _vcsProvider.Received(1).GetReleaseAsync(OWNER, REPOSITORY, MILESTONE_TITLE).ConfigureAwait(false);
354+
await _vcsProvider.Received(1).CreateReleaseAsync(OWNER, REPOSITORY, Arg.Is<Release>(o =>
355+
o.Body == RELEASE_NOTES &&
356+
o.Name == MILESTONE_TITLE &&
357+
o.TagName == MILESTONE_TITLE)).ConfigureAwait(false);
358+
359+
_logger.Received(1).Verbose(Arg.Any<string>(), MILESTONE_TITLE, OWNER, REPOSITORY);
360+
_logger.Received(1).Debug(Arg.Any<string>(), Arg.Any<Release>());
361+
}
362+
324363
[Test]
325364
public async Task Should_Create_Release_From_Milestone_Using_Template_File()
326365
{

0 commit comments

Comments
 (0)