Exemple #1
0
        public void PublishBasicReleaseWorksCorrectly()
        {
            // arrange
            var fixture         = new CakeOctoDeployAliasFixture();
            var responseFixture = new GitHubResponseHelper();

            OctoDeployAlias.GitHubApiBaseUrl = GitHubRequestFixture.BaseUrl;
            var httpMock = HttpMockRepository.At(GitHubRequestFixture.BaseUrl);

            responseFixture.SetupHttpMockWithValidResponseForReleaseCreation(httpMock, fixture.OctoSettingMock);

            // act
            var result = fixture.GetCakeContext.PublishRelease(GitHubRequestFixture.Tag, GitHubRequestFixture.Title, GitHubRequestFixture.ReleaseNotes,
                                                               GitHubRequestFixture.IsDraft, GitHubRequestFixture.IsPreRelease, fixture.OctoSettingMock.GetSettings);

            // assert
            result.Should().Be(GitHubResponseHelper.ReleaseId);
        }
Exemple #2
0
        public void ErrorDuringAssetUploadThrowsAnException()
        {
            // arrange
            var fixture       = new CakeOctoDeployAliasFixture();
            var responseDummy = new GitHubResponseHelper($"{GitHubRequestFixture.BaseUrl}/repos/{fixture.OctoSettingMock.Owner}/{fixture.OctoSettingMock.Repository}/releases/{GitHubResponseHelper.ReleaseId}/assets{{?name,label}}");

            OctoDeployAlias.GitHubApiBaseUrl = GitHubRequestFixture.BaseUrl;
            var httpMock = HttpMockRepository.At(GitHubRequestFixture.BaseUrl);

            responseDummy.SetupHttpMockWithValidResponseForReleaseRetrieval(httpMock, fixture.OctoSettingMock);
            responseDummy.SetupHttpMockWithInvalidAssetUploadResponse(httpMock, fixture.OctoSettingMock);

            var act = new Action(() => fixture.GetCakeContext.UploadArtifact(GitHubResponseHelper.ReleaseId, GitHubRequestFixture.Artifact1FilePath, GitHubRequestFixture.Artifact1Name, GitHubRequestFixture.MimeType, fixture.OctoSettingMock.GetSettings));

            // act
            // assert
            act.ShouldThrow <CakeException>("Unknown error occured while creating release");
        }
Exemple #3
0
        public void PublishReleaseWithArtifactsThrowsAnExceptionIfAllArraysAreNotTheSameSize()
        {
            // arrange
            var fixture         = new CakeOctoDeployAliasFixture();
            var responseFixture = new GitHubResponseHelper($"{GitHubRequestFixture.BaseUrl}/repos/{fixture.OctoSettingMock.Owner}/{fixture.OctoSettingMock.Repository}/releases/{GitHubResponseHelper.ReleaseId}/assets{{?name,label}}");

            var act = new Action(() =>
            {
                fixture.GetCakeContext.PublishReleaseWithArtifacts(GitHubRequestFixture.Tag, GitHubRequestFixture.Title, GitHubRequestFixture.ReleaseNotes,
                                                                   GitHubRequestFixture.IsDraft, GitHubRequestFixture.IsPreRelease, new[] { new FilePath("blah") }, new[] { "art1", "art2" }, new[] { "mime1" },
                                                                   fixture.OctoSettingMock.GetSettings);
            });

            // act
            // assert
            act.ShouldThrow <CakeException>(
                "ArtifactPaths, ArtifactNames and ArtifactMimeTypes all need to be the same length");
        }
Exemple #4
0
        public void UploadArtifactWorksCorrectly()
        {
            // arrange
            var fixture       = new CakeOctoDeployAliasFixture();
            var responseDummy = new GitHubResponseHelper($"{GitHubRequestFixture.BaseUrl}/repos/{fixture.OctoSettingMock.Owner}/{fixture.OctoSettingMock.Repository}/releases/{GitHubResponseHelper.ReleaseId}/assets{{?name,label}}");

            OctoDeployAlias.GitHubApiBaseUrl = GitHubRequestFixture.BaseUrl;
            var httpMock = HttpMockRepository.At(GitHubRequestFixture.BaseUrl);

            responseDummy.SetupHttpMockWithValidResponseForReleaseRetrieval(httpMock, fixture.OctoSettingMock);
            responseDummy.SetupHttpMockWithValidAssetUploadResponse(httpMock, fixture.OctoSettingMock);

            // act
            fixture.GetCakeContext.UploadArtifact(GitHubResponseHelper.ReleaseId, GitHubRequestFixture.Artifact1FilePath, GitHubRequestFixture.Artifact1Name, GitHubRequestFixture.MimeType, fixture.OctoSettingMock.GetSettings);

            // assert
            fixture.GetCakeLog.Messages.Last()
            .Format.Should()
            .Be($"Uploaded artifact {GitHubRequestFixture.Artifact1FilePath.FullPath} to GitHub. Id {123}");
        }
Exemple #5
0
        public void PublishArtifactsWithReleaseNotesFileWorksCorrectly()
        {
            // arrange
            var fixture         = new CakeOctoDeployAliasFixture();
            var responseFixture = new GitHubResponseHelper($"{GitHubRequestFixture.BaseUrl}/repos/{fixture.OctoSettingMock.Owner}/{fixture.OctoSettingMock.Repository}/releases/{GitHubResponseHelper.ReleaseId}/assets{{?name,label}}");

            OctoDeployAlias.GitHubApiBaseUrl = GitHubRequestFixture.BaseUrl;
            var httpMock = HttpMockRepository.At(GitHubRequestFixture.BaseUrl);

            responseFixture.SetupHttpMockWithValidResponseForReleaseCreation(httpMock, fixture.OctoSettingMock);
            responseFixture.SetupHttpMockWithValidResponseForReleaseRetrieval(httpMock, fixture.OctoSettingMock);
            responseFixture.SetupHttpMockWithValidAssetUploadResponse(httpMock, fixture.OctoSettingMock);

            var act = new Action(() =>
            {
                fixture.GetCakeContext.PublishReleaseWithArtifacts(GitHubRequestFixture.Tag, GitHubRequestFixture.Title, GitHubRequestFixture.ReleaseNotesFilePath,
                                                                   GitHubRequestFixture.IsDraft, GitHubRequestFixture.IsPreRelease, new[] { GitHubRequestFixture.Artifact1FilePath, GitHubRequestFixture.Artifact2FilePath },
                                                                   new[] { GitHubRequestFixture.Artifact1Name, GitHubRequestFixture.Artifact2Name }, new[] { GitHubRequestFixture.MimeType, GitHubRequestFixture.MimeType }, fixture.OctoSettingMock.GetSettings);
            });

            // act
            // assert
            act.ShouldNotThrow <CakeException>();
        }