public void PicksUpBranchNameFromEnvironment()
        {
            environment.SetEnvironmentVariable(CodeBuild.HeadRefEnvironmentName, "refs/heads/master");
            var cb = new CodeBuild(environment, log);

            cb.GetCurrentBranch(false).ShouldBe("refs/heads/master");
        }
        private void AssertVariablesAreWrittenToFile(string f)
        {
            var writes          = new List <string>();
            var semanticVersion = new SemanticVersion
            {
                Major         = 1,
                Minor         = 2,
                Patch         = 3,
                PreReleaseTag = "beta1",
                BuildMetaData = "5"
            };

            semanticVersion.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");
            semanticVersion.BuildMetaData.Sha        = "commitSha";

            var config = new TestEffectiveConfiguration();

            var variables = variableProvider.GetVariablesFor(semanticVersion, config, false);

            var j = new CodeBuild(environment, log, f);

            j.WriteIntegration(writes.Add, variables);

            writes[1].ShouldBe("1.2.3-beta.1+5");

            File.Exists(f).ShouldBe(true);

            var props = File.ReadAllText(f);

            props.ShouldContain("GitVersion_Major=1");
            props.ShouldContain("GitVersion_Minor=2");
        }
        public void CorrectlyIdentifiesCodeBuildPresence()
        {
            environment.SetEnvironmentVariable(CodeBuild.HeadRefEnvironmentName, "a value");
            var cb = new CodeBuild(environment, log);

            cb.CanApplyToCurrentContext().ShouldBe(true);
        }
示例#4
0
 public void SetUp()
 {
     sp = ConfigureServices(services =>
     {
         services.AddSingleton <CodeBuild>();
     });
     environment = sp.GetService <IEnvironment>();
     buildServer = sp.GetService <CodeBuild>();
 }
示例#5
0
 public void SetUp()
 {
     this.sp          = ConfigureServices(services => services.AddSingleton <CodeBuild>());
     this.environment = this.sp.GetRequiredService <IEnvironment>();
     this.buildServer = this.sp.GetRequiredService <CodeBuild>();
 }