public void GeneratedSnippet_HasInstallationScript() { // Arrange var expectedScript = "test-script"; var commonOptions = new BuildScriptGeneratorOptions(); commonOptions.EnableDynamicInstall = true; var golangPlatform = CreateGolangPlatform( commonOptions: commonOptions, isGolangVersionAlreadyInstalled: false, golangInstallationScript: expectedScript); var repo = new MemorySourceRepo(); repo.AddFile("{}", GolangConstants.GoModFileName); var context = CreateContext(repo); var detectedResult = new GolangPlatformDetectorResult { Platform = GolangConstants.PlatformName, PlatformVersion = "1.17", }; // Act var actualScriptSnippet = golangPlatform.GetInstallerScriptSnippet(context, detectedResult); // Assert Assert.NotNull(actualScriptSnippet); Assert.Contains(expectedScript, actualScriptSnippet); }
private void ResolveVersionsUsingHierarchicalRules(GolangPlatformDetectorResult detectorResult) { var goVersion = ResolveGoVersion(detectorResult.PlatformVersion); goVersion = this.GetMaxSatisfyingGoVersionAndVerify(goVersion); detectorResult.PlatformVersion = goVersion; string ResolveGoVersion(string detectedVersion) { // Explicitly specified version by user wins over detected version if (!string.IsNullOrEmpty(this.goScriptGeneratorOptions.GolangVersion)) { return(this.goScriptGeneratorOptions.GolangVersion); } // If a version was detected, then use it. if (detectedVersion != null) { return(detectedVersion); } // Fallback to default version var versionInfo = this.goVersionProvider.GetVersionInfo(); return(versionInfo.DefaultVersion); } }