public async Task WarnsWhenVariableIsNotInPackage()
        {
            // arrange
            var packageId         = new PackageIdentity("Lineup", NuGetVersion.Parse("1.0.0"));
            var lineupPackagePath = CreateLineup(packageId);
            var depsFilePath      = CreateProjectDepsFile(("PackageVersionVar", "1.0.0"));
            var engine            = new MockEngine(_output);

            // act
            var task = new UpgradeDependencies
            {
                BuildEngine                = engine,
                DependenciesFile           = depsFilePath,
                LineupPackageId            = packageId.Id,
                LineupPackageRestoreSource = _tempDir,
            };

            // assert
            Assert.True(await task.ExecuteAsync(), "Task is expected to pass");
            var warning = Assert.Single(engine.Warnings);

            Assert.Equal(KoreBuildErrors.Prefix + KoreBuildErrors.PackageVersionNotFoundInLineup, warning.Code);

            var modifiedDepsFile = DependencyVersionsFile.Load(depsFilePath);

            Assert.Equal("1.0.0", modifiedDepsFile.VersionVariables["PackageVersionVar"]);
        }
        public async Task DoesNotModifiesFileIfNoChanges()
        {
            // arrange
            var packageId         = new PackageIdentity("Lineup", NuGetVersion.Parse("1.0.0"));
            var pkg               = ("PackageVersionVar", "1.0.0");
            var lineupPackagePath = CreateLineup(packageId, pkg);
            var depsFilePath      = CreateProjectDepsFile(pkg);
            var created           = File.GetLastWriteTime(depsFilePath);

            // act
            var task = new UpgradeDependencies
            {
                BuildEngine                = new MockEngine(_output),
                DependenciesFile           = depsFilePath,
                LineupPackageId            = packageId.Id,
                LineupPackageRestoreSource = _tempDir,
            };

            // assert
            Assert.True(await task.ExecuteAsync(), "Task is expected to pass");
            var modifiedDepsFile = DependencyVersionsFile.Load(depsFilePath);

            Assert.Equal("1.0.0", modifiedDepsFile.VersionVariables["PackageVersionVar"]);
            Assert.Equal(created, File.GetLastWriteTime(depsFilePath));
        }
Beispiel #3
0
        public async Task DoesNotModifyPinnedVariableValue()
        {
            // arrange
            var packageId         = new PackageIdentity("Lineup", NuGetVersion.Parse("1.0.0"));
            var lineupPackagePath = CreateLineup(packageId, new VersionVariable("PackageVersionVar", "2.0.0"));
            var depsFilePath      = CreateProjectDepsFile(new VersionVariable("PackageVersionVar", "1.0.0")
            {
                IsReadOnly = true
            });

            // act
            var task = new UpgradeDependencies
            {
                BuildEngine                = new MockEngine(_output),
                DependenciesFile           = depsFilePath,
                LineupPackageId            = packageId.Id,
                LineupPackageRestoreSource = _tempDir,
            };

            // assert
            Assert.True(await task.ExecuteAsync(), "Task is expected to pass");
            _output.WriteLine(File.ReadAllText(depsFilePath));
            var modifiedDepsFile = DependencyVersionsFile.Load(depsFilePath);

            Assert.Equal("1.0.0", modifiedDepsFile.VersionVariables["PackageVersionVar"].Version);
            Assert.True(modifiedDepsFile.VersionVariables["PackageVersionVar"].IsReadOnly);
        }
        public async Task ModifiesVariableValueUsingDepsFile()
        {
            // arrange
            var depsFilePath        = CreateProjectDepsFile(("PackageVersionVar", "1.0.0"));
            var updatedDepsFilePath = CreateProjectDepsFile(Path.Combine(_tempDir, "dependencies.props"), ("PackageVersionVar", "2.0.0"));

            // act
            var task = new UpgradeDependencies
            {
                BuildEngine            = new MockEngine(_output),
                DependenciesFile       = depsFilePath,
                LineupDependenciesFile = updatedDepsFilePath
            };

            // assert
            Assert.True(await task.ExecuteAsync(), "Task is expected to pass");
            var modifiedDepsFile = DependencyVersionsFile.Load(depsFilePath);

            Assert.Equal("2.0.0", modifiedDepsFile.VersionVariables["PackageVersionVar"]);
        }
        public async Task SnapsInternalAspNetCoreSdkToBuildTools()
        {
            // arrange
            var packageId         = new PackageIdentity("Lineup", NuGetVersion.Parse("1.0.0"));
            var lineupPackagePath = CreateLineup(packageId, ("InternalAspNetCoreSdkPackageVersion", "2.0.0"));
            var depsFilePath      = CreateProjectDepsFile(("InternalAspNetCoreSdkPackageVersion", "1.0.0"));

            // act
            var task = new UpgradeDependencies
            {
                BuildEngine                = new MockEngine(_output),
                DependenciesFile           = depsFilePath,
                LineupPackageId            = packageId.Id,
                LineupPackageRestoreSource = _tempDir,
            };

            // assert
            Assert.True(await task.ExecuteAsync(), "Task is expected to pass");
            var modifiedDepsFile = DependencyVersionsFile.Load(depsFilePath);

            Assert.Equal(KoreBuildVersion.Current, modifiedDepsFile.VersionVariables["InternalAspNetCoreSdkPackageVersion"]);
        }