Files
runner/src/Test/L0/DotnetsdkDownloadScriptL0.cs
T

72 lines
2.8 KiB
C#
Raw Normal View History

2019-10-10 00:52:42 -04:00
using Xunit;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
2021-02-04 22:58:10 -05:00
using System;
2019-10-10 00:52:42 -04:00
namespace GitHub.Runner.Common.Tests
{
public sealed class DotnetsdkDownloadScriptL0
{
[Fact]
[Trait("Level", "L0")]
2019-12-09 17:54:41 -05:00
[Trait("Category", "Runner")]
2019-10-10 00:52:42 -04:00
public async Task EnsureDotnetsdkBashDownloadScriptUpToDate()
{
2021-02-04 22:58:10 -05:00
if ((DateTime.UtcNow.Month - 1) % 3 != 0)
{
// Only check these script once a quater.
return;
}
2019-10-10 00:52:42 -04:00
string shDownloadUrl = "https://dot.net/v1/dotnet-install.sh";
using (HttpClient downloadClient = new HttpClient())
{
var response = await downloadClient.GetAsync("https://www.bing.com");
if (!response.IsSuccessStatusCode)
{
return;
}
string shScript = await downloadClient.GetStringAsync(shDownloadUrl);
string existingShScript = File.ReadAllText(Path.Combine(TestUtil.GetSrcPath(), "Misc/dotnet-install.sh"));
bool shScriptMatched = string.Equals(shScript.TrimEnd('\n', '\r', '\0').Replace("\r\n", "\n").Replace("\r", "\n"), existingShScript.TrimEnd('\n', '\r', '\0').Replace("\r\n", "\n").Replace("\r", "\n"));
2021-07-08 17:22:46 -04:00
//Assert.True(shScriptMatched, "Fix the test by updating Src/Misc/dotnet-install.sh with content from https://dot.net/v1/dotnet-install.sh");
2019-10-10 00:52:42 -04:00
}
}
[Fact]
[Trait("Level", "L0")]
2019-12-09 17:54:41 -05:00
[Trait("Category", "Runner")]
2019-10-10 00:52:42 -04:00
public async Task EnsureDotnetsdkPowershellDownloadScriptUpToDate()
{
2021-02-04 22:58:10 -05:00
if ((DateTime.UtcNow.Month - 1) % 3 != 0)
{
// Only check these script once a quater.
return;
}
2019-10-10 00:52:42 -04:00
string ps1DownloadUrl = "https://dot.net/v1/dotnet-install.ps1";
using (HttpClient downloadClient = new HttpClient())
{
var response = await downloadClient.GetAsync("https://www.bing.com");
if (!response.IsSuccessStatusCode)
{
return;
}
string ps1Script = await downloadClient.GetStringAsync(ps1DownloadUrl);
string existingPs1Script = File.ReadAllText(Path.Combine(TestUtil.GetSrcPath(), "Misc/dotnet-install.ps1"));
bool ps1ScriptMatched = string.Equals(ps1Script.TrimEnd('\n', '\r', '\0').Replace("\r\n", "\n").Replace("\r", "\n"), existingPs1Script.TrimEnd('\n', '\r', '\0').Replace("\r\n", "\n").Replace("\r", "\n"));
2021-07-08 17:22:46 -04:00
//Assert.True(ps1ScriptMatched, "Fix the test by updating Src/Misc/dotnet-install.ps1 with content from https://dot.net/v1/dotnet-install.ps1");
2019-10-10 00:52:42 -04:00
}
}
}
}