Example #1
0
        public void CreatesTopLevelTrackingConfig()
        {
            using (TestHostContext hc = Setup())
            {
                // Arrange.
                string         trackingFile = Path.Combine(_workFolder, "trackingconfig.json");
                DateTimeOffset testStartOn  = DateTimeOffset.Now;

                // Act.
                _trackingManager.Create(_ec.Object, _repository, "some hash key", trackingFile, false);

                // Assert.
                string topLevelFile = Path.Combine(
                    _workFolder,
                    Constants.Build.Path.SourceRootMappingDirectory,
                    Constants.Build.Path.TopLevelTrackingConfigFile);
                var config = JsonConvert.DeserializeObject <TopLevelTrackingConfig>(
                    value: File.ReadAllText(topLevelFile));
                Assert.Equal(1, config.LastBuildDirectoryNumber);
                // Manipulate the expected seconds due to loss of granularity when the
                // date-time-offset is serialized in a friendly format.
                Assert.True(testStartOn.AddSeconds(-1) <= config.LastBuildDirectoryCreatedOn);
                Assert.True(DateTimeOffset.Now.AddSeconds(1) >= config.LastBuildDirectoryCreatedOn);
            }
        }
Example #2
0
        public void CreatesTrackingConfig()
        {
            using (TestHostContext hc = Setup())
            {
                // Arrange.
                string         trackingFile = Path.Combine(_workFolder, "trackingconfig.json");
                DateTimeOffset testStartOn  = DateTimeOffset.Now;

                // Act.
                _trackingManager.Create(_ec.Object, trackingFile);

                // Assert.
                TrackingConfig config = _trackingManager.LoadIfExists(_ec.Object, trackingFile);
                Assert.Equal("runner", config.PipelineDirectory);
                Assert.Equal($"runner{Path.DirectorySeparatorChar}runner", config.WorkspaceDirectory);
                Assert.Equal("actions/runner", config.RepositoryName);

                Assert.Equal(1, config.Repositories.Count);
                Assert.Equal($"runner{Path.DirectorySeparatorChar}runner", config.Repositories["actions/runner"].RepositoryPath);

                // Manipulate the expected seconds due to loss of granularity when the
                // date-time-offset is serialized in a friendly format.
                Assert.True(testStartOn.AddSeconds(-1) <= config.LastRunOn);
                Assert.True(DateTimeOffset.Now.AddSeconds(1) >= config.LastRunOn);
            }
        }