コード例 #1
0
ファイル: RubyPlatformTests.cs プロジェクト: sujithq/Oryx
        public void Detect_ReturnsVersionFromOptions_EvenIfDetectorReturnsVersion()
        {
            // Arrange
            var expectedVersion            = "2.7.1";
            var detectedVersion            = "2.6.6";
            var defaultVersion             = "2.7.1";
            var rubyScriptGeneratorOptions = new RubyScriptGeneratorOptions
            {
                RubyVersion = expectedVersion
            };
            var platform = CreateRubyPlatform(
                supportedRubyVersions: new[] { expectedVersion },
                defaultVersion: defaultVersion,
                detectedVersion: detectedVersion,
                rubyScriptGeneratorOptions: rubyScriptGeneratorOptions);
            var context = CreateContext();

            // Act
            var result = platform.Detect(context);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(RubyConstants.PlatformName, result.Platform);
            Assert.Equal(expectedVersion, result.PlatformVersion);
        }
コード例 #2
0
ファイル: RubyPlatformTests.cs プロジェクト: sujithq/Oryx
        private RubyPlatform CreateRubyPlatform(
            string[] supportedRubyVersions                        = null,
            string defaultVersion                                 = null,
            string detectedVersion                                = null,
            BuildScriptGeneratorOptions commonOptions             = null,
            RubyScriptGeneratorOptions rubyScriptGeneratorOptions = null,
            bool?isRubyVersionAlreadyInstalled                    = null,
            string rubyInstallationScript                         = null)
        {
            commonOptions = commonOptions ?? new BuildScriptGeneratorOptions();
            rubyScriptGeneratorOptions    = rubyScriptGeneratorOptions ?? new RubyScriptGeneratorOptions();
            isRubyVersionAlreadyInstalled = isRubyVersionAlreadyInstalled ?? true;
            rubyInstallationScript        = rubyInstallationScript ?? "default-ruby-installation-script";
            var versionProvider = new TestRubyVersionProvider(supportedRubyVersions, defaultVersion);
            var detector        = new TestRubyPlatformDetector(detectedVersion: detectedVersion);
            var rubyInstaller   = new TestRubyPlatformInstaller(
                Options.Create(commonOptions),
                isRubyVersionAlreadyInstalled.Value,
                rubyInstallationScript);

            return(new TestRubyPlatform(
                       Options.Create(rubyScriptGeneratorOptions),
                       Options.Create(commonOptions),
                       versionProvider,
                       NullLogger <TestRubyPlatform> .Instance,
                       detector,
                       rubyInstaller));
        }
コード例 #3
0
ファイル: RubyPlatformTests.cs プロジェクト: maxwellb/Oryx
        public void GeneratedBuildSnippet_CustomBuildCommandWillExecute_WhenOtherCommandsAlsoExist()
        {
            // Arrange
            var commonOptions = new BuildScriptGeneratorOptions();

            commonOptions.AppType = Constants.StaticSiteApplications;
            var rubyScriptGeneratorOptions = new RubyScriptGeneratorOptions
            {
                CustomBuildCommand = "custom build command"
            };
            var rubyPlatform = CreateRubyPlatform(
                rubyScriptGeneratorOptions: rubyScriptGeneratorOptions,
                commonOptions: commonOptions,
                isRubyVersionAlreadyInstalled: false);
            var repo = new MemorySourceRepo();

            repo.AddFile(string.Empty, RubyConstants.GemFileName);
            var context        = CreateContext(repo);
            var detectorResult = new RubyPlatformDetectorResult
            {
                Platform        = RubyConstants.PlatformName,
                PlatformVersion = "2.6.6",
                GemfileExists   = true,
            };

            // Act
            var buildScriptSnippet = rubyPlatform.GenerateBashBuildScriptSnippet(context, detectorResult);

            // Assert
            Assert.NotNull(buildScriptSnippet);
            Assert.DoesNotContain("gem install jekyll", buildScriptSnippet.BashBuildScriptSnippet);
            Assert.DoesNotContain("jekyll build", buildScriptSnippet.BashBuildScriptSnippet);
            Assert.DoesNotContain("bundle install", buildScriptSnippet.BashBuildScriptSnippet);
            Assert.Contains("custom build command", buildScriptSnippet.BashBuildScriptSnippet);
        }
コード例 #4
0
ファイル: RubyPlatformTests.cs プロジェクト: sujithq/Oryx
        public void Detect_Throws_WhenUnsupportedRubyVersion_IsSetInOptions()
        {
            // Arrange
            var versionFromOptions         = "0";
            var supportedVersion           = "2.7.1";
            var rubyScriptGeneratorOptions = new RubyScriptGeneratorOptions
            {
                RubyVersion = versionFromOptions
            };
            var platform = CreateRubyPlatform(
                supportedRubyVersions: new[] { supportedVersion },
                defaultVersion: supportedVersion,
                detectedVersion: supportedVersion,
                rubyScriptGeneratorOptions: rubyScriptGeneratorOptions);
            var context = CreateContext();

            // Act & Assert
            var exception = Assert.Throws <UnsupportedVersionException>(() => platform.Detect(context));

            Assert.Equal(
                $"Platform 'ruby' version '{versionFromOptions}' is unsupported. " +
                $"Supported versions: {supportedVersion}",
                exception.Message);
        }