示例#1
0
        public async Task WaitForDropArtifactBuildFailedTest()
        {
            // given
            var buildClient = new MockBuildClient()
            {
                MockBuild = new Build()
                {
                    Status = BuildStatus.Completed, Result = BuildResult.Failed, Repository = new BuildRepository()
                    {
                        Name = "someRepo"
                    }
                },
            };
            var gitClient      = new MockGitClient();
            var releaseClient  = new MockReleaseClient();
            var artifactHelper = new VstsArtifactsHelper(buildClient: buildClient, releaseClient: releaseClient, gitClient: gitClient, projectId: Guid.NewGuid(), repoName: "someRepo");

            // when
            var throws = false;

            try
            {
                await artifactHelper.WaitForDropArtifact("someArtifact", 123, default(CancellationToken));
            }
            catch (VstsArtifactsNotFoundException)
            {
                throws = true;
            }

            // then
            Assert.IsTrue(throws);
        }
示例#2
0
        public async Task WaitForDropArtifactBuildNotFoundTest()
        {
            // given
            var buildClient = new MockBuildClient()
            {
                ReturnNullBuild = true,
            };
            var releaseClient  = new MockReleaseClient();
            var gitClient      = new MockGitClient();
            var artifactHelper = new VstsArtifactsHelper(buildClient: buildClient, releaseClient: releaseClient, gitClient: gitClient, projectId: Guid.NewGuid(), repoName: "someRepo");

            // when
            var throws = false;

            try
            {
                await artifactHelper.WaitForDropArtifact("someArtifact", 123, default(CancellationToken));
            }
            catch (ArgumentException)
            {
                throws = true;
            }

            // then
            Assert.IsTrue(throws);
        }
示例#3
0
        public async Task WaitForDropArtifactGoldenPathTest()
        {
            // given
            var expectedContent = "{\"VstsDropBuildArtifact\":{\"VstsDropUrl\":\"https://someartifacturl\"}}";
            var entryName       = string.Format("{0}/{1}", Guid.NewGuid(), VstsArtifactsHelper.VstsDropJsonFileName);
            var buildClient     = new MockBuildClient()
            {
                MockBuild = new Build()
                {
                    Status = BuildStatus.Completed, Result = BuildResult.Succeeded
                },
                MockBuildArtifact = new BuildArtifact(),
                ContentStream     = GetZippedStream(expectedContent, entryName),
            };
            var gitClient      = new MockGitClient();
            var releaseClient  = new MockReleaseClient();
            var artifactHelper = new VstsArtifactsHelper(buildClient: buildClient, releaseClient: releaseClient, gitClient: gitClient, projectId: Guid.NewGuid(), repoName: "someRepo");

            // when
            var artifactUrl = await artifactHelper.WaitForDropArtifact("someArtifact", 123, default(CancellationToken));

            // then
            Assert.AreEqual("https://someartifacturl", artifactUrl);
        }