Esempio n. 1
0
            public void Should_Log_GitVersion_Errors_When_Verbosity_Less_Than_Diagnostic(Verbosity verbosity)
            {
                // Given
                var log = new FakeLog {
                    Verbosity = verbosity
                };
                var fixture = new GitVersionRunnerFixture(new[]
                {
                    "  INFO [02/29/20 20:29:12:17] No local branch pointing at the commit '57a682f6012d1f27255de86240fa98e87fe1f765'. Fake branch needs to be created.  INFO [02/29/20 20:29:12:17] Fetching remote refs to see if there is a pull request ref  INFO [02/29/20 20:29:12:20] End: Normalizing git directory for branch '' (Took: 89.28ms)  ERROR [02/29/20 20:29:12:21] An unexpected error occurred:",
                    "LibGit2Sharp.LibGit2SharpException: this remote has never connected",
                    "   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)",
                    "...",
                    "  INFO [02/29/20 20:43:18:60] No local branch pointing at the commit 'c9d51bc9836a310145b3d8976a69b1859be36a35'. Fake branch needs to be created.",
                    "  INFO [02/29/20 20:43:18:60] Fetching remote refs to see if there is a pull request ref",
                    "  INFO [02/29/20 20:43:18:66] End: Normalizing git directory for branch '' (Took: 124.33ms)",
                    "  ERROR [02/29/20 20:43:18:68] An unexpected error occurred:",
                    "LibGit2Sharp.LibGit2SharpException: this remote has never connected",
                    "   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)",
                    "..."
                });

                fixture.Log = log;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.Equal(verbosity < Verbosity.Diagnostic
                    ? "  ERROR [02/29/20 20:29:12:21] An unexpected error occurred:" + Environment.NewLine +
                             "LibGit2Sharp.LibGit2SharpException: this remote has never connected" + Environment.NewLine +
                             "  ERROR [02/29/20 20:43:18:68] An unexpected error occurred:" + Environment.NewLine +
                             "LibGit2Sharp.LibGit2SharpException: this remote has never connected" + Environment.NewLine
                    : string.Empty,
                             log.AggregateLogMessages());
            }
Esempio n. 2
0
            public void Should_Set_Working_Directory()
            {
                // Given
                var fixture = new GitVersionRunnerFixture();
                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Working", result.Process.WorkingDirectory.FullPath);
            }
Esempio n. 3
0
            public void Should_Find_GitVersion_Runner()
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Working/tools/GitVersion.exe", result.Path.FullPath);
            }
Esempio n. 4
0
            public void Should_Throw_If_Settings_Is_Null()
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.Settings = null;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsArgumentNullException(result, "settings");
            }
Esempio n. 5
0
            public void Should_Add_ShowVariable_To_Arguments_If_Set()
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.Settings.ShowVariable = "FullSemVer";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/showvariable FullSemVer", result.Args);
            }
            public void Should_Add_Default_Verbosity_To_Arguments_If_Not_Set(Verbosity verbosity, string arg)
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.SetLogVerbosity(verbosity);

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal($"-verbosity {arg}", result.Args);
            }
            public void Should_Add_Verbosity_To_Arguments_If_Set(GitVersionVerbosity verbosity, string arg)
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.Settings.Verbosity = verbosity;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal($"-verbosity {arg}", result.Args);
            }
            public void Should_Add_NoFetch_To_Arguments_If_Set(bool nofetch, string args)
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.Settings.NoFetch = nofetch;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal(args, result.Args);
            }
Esempio n. 9
0
            public void Should_Add_RepositoryPath_To_Arguments_If_Set()
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.Settings.RepositoryPath = "c:/temp";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/targetpath \"c:/temp\"", result.Args);
            }
Esempio n. 10
0
            public void Should_Add_OutputType_To_Arguments_If_Set()
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.Settings.OutputType = GitVersionOutput.Json;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/output json", result.Args);
            }
Esempio n. 11
0
            public void Should_Add_LogFilePath_To_Arguments_If_Set()
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.Settings.LogFilePath = "c:/temp/gitversion.log";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/l \"c:/temp/gitversion.log\"", result.Args);
            }
Esempio n. 12
0
            public void Should_Add_UpdateAssemblyInfo_To_Arguments_If_Set()
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.Settings.UpdateAssemblyInfo = true;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/updateassemblyinfo", result.Args);
            }
Esempio n. 13
0
            public void Should_Add_Username_And_Password_To_Arguments_If_Set()
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.Settings.UserName = "******";
                fixture.Settings.Password = "******";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/u \"bob\" /p \"password\"", result.Args);
            }
Esempio n. 14
0
            public void Should_Throw_If_Has_A_Non_Zero_Exit_Code()
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.GivenProcessExitsWithCode(1);

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("GitVersion: Process returned an error (exit code 1).", result.Message);
            }
Esempio n. 15
0
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.GivenProcessCannotStart();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("GitVersion: Process was not started.", result.Message);
            }
            public void Should_Add_UpdateAssemblyInfoFilePath_To_Arguments_If_Set()
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.Settings.UpdateAssemblyInfo         = true;
                fixture.Settings.UpdateAssemblyInfoFilePath = "c:/temp/assemblyinfo.cs";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("-updateassemblyinfo \"c:/temp/assemblyinfo.cs\"", result.Args);
            }
Esempio n. 17
0
            public void Should_Add_DynamicRepoSettings_To_Arguments_If_Set()
            {
                // Given
                var fixture = new GitVersionRunnerFixture();

                fixture.Settings.Url    = "http://mygitrepo.co.uk";
                fixture.Settings.Branch = "master";
                fixture.Settings.Commit = "abcdef";
                fixture.Settings.DynamicRepositoryPath = "c:/temp";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/url \"http://mygitrepo.co.uk\" /b master /c \"abcdef\" /dynamicRepoLocation \"c:/temp\"", result.Args);
            }