Пример #1
0
        public void Feed_LocalTypeSupportsRelativePath(string configPath, string outputPath, string expected)
        {
            using (var cache = new LocalCache())
            {
                var baseUri = UriUtility.CreateUri("https://localhost:8080/testFeed/");

                var sleetConfig = TestUtility.CreateConfigWithLocal("local", outputPath, baseUri.AbsoluteUri);

                var settings   = LocalSettings.Load(sleetConfig, configPath);
                var fileSystem = FileSystemFactory.CreateFileSystem(settings, cache, "local") as PhysicalFileSystem;

                Assert.NotNull(fileSystem);
                Assert.Equal(expected, fileSystem.LocalRoot);
            }
        }
Пример #2
0
        public async Task Feed_LocalTypeSupportsRelativePath(string configPath, string outputPath, string expected)
        {
            var expectedFull = expected.Replace("{workingDir}", Directory.GetCurrentDirectory());

            using (var cache = new LocalCache())
            {
                var baseUri = UriUtility.CreateUri("https://localhost:8080/testFeed/");

                var sleetConfig = TestUtility.CreateConfigWithLocal("local", outputPath, baseUri.AbsoluteUri);

                var settings   = LocalSettings.Load(sleetConfig, configPath);
                var fileSystem = await FileSystemFactory.CreateFileSystemAsync(settings, cache, "local") as PhysicalFileSystem;

                Assert.NotNull(fileSystem);
                Assert.Equal(expectedFull, fileSystem.LocalRoot);
            }
        }
Пример #3
0
        public async Task BaseUri_VerifyBaseUriIsSetForAllFilesAsync()
        {
            // Arrange
            using (var packagesFolder = new TestFolder())
                using (var target = new TestFolder())
                    using (var cache = new LocalCache())
                    {
                        var outputRoot = Path.Combine(target.Root, "output");
                        var baseUri    = UriUtility.CreateUri("https://localhost:8080/testFeed/");

                        var log = new TestLogger();

                        var testPackage = new TestNupkg("packageA", "1.0.0");

                        var sleetConfig = TestUtility.CreateConfigWithLocal("local", outputRoot, baseUri.AbsoluteUri);

                        var sleetConfigPath = Path.Combine(target.Root, "sleet.config");
                        await JsonUtility.SaveJsonAsync(new FileInfo(sleetConfigPath), sleetConfig);

                        var zipFile = testPackage.Save(packagesFolder.Root);

                        var settings   = LocalSettings.Load(sleetConfigPath);
                        var fileSystem = await FileSystemFactory.CreateFileSystemAsync(settings, cache, "local");

                        // Act
                        var initSuccess = await InitCommand.RunAsync(settings, fileSystem, log);

                        var pushSuccess = await PushCommand.RunAsync(settings, fileSystem, new List <string>() { zipFile.FullName }, false, false, log);


                        // Assert
                        Assert.True(initSuccess, log.ToString());
                        Assert.True(pushSuccess, log.ToString());

                        var files = Directory.GetFiles(outputRoot, "*.json", SearchOption.AllDirectories);
                        await BaseURITestUtil.VerifyBaseUris(files, baseUri);
                    }
        }
Пример #4
0
        public void UriUtility_ThrowsIfGetAbsolutePathWithNoSettingsFile()
        {
            Exception ex = null;

            try
            {
                using (var cache = new LocalCache())
                {
                    var baseUri = UriUtility.CreateUri("https://localhost:8080/testFeed/");

                    var sleetConfig = TestUtility.CreateConfigWithLocal("local", "relativePath", baseUri.AbsoluteUri);

                    var settings = LocalSettings.Load(sleetConfig, null);
                    FileSystemFactory.CreateFileSystem(settings, cache, "local");
                }
            }
            catch (Exception e)
            {
                ex = e;
            }

            ex.Should().NotBeNull();
            ex.Message.Should().Be("Cannot use a relative 'path' without a settings.json file.");
        }