|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Text; |
| 4 | +using NUnit.Framework; |
| 5 | + |
| 6 | +namespace Xtensive.Orm.Tests |
| 7 | +{ |
| 8 | + |
| 9 | + [TestFixture] |
| 10 | + public sealed class TestInfoTest |
| 11 | + { |
| 12 | + [Test] |
| 13 | + public void IsBuildServerTest() |
| 14 | + { |
| 15 | + var teamCityVersion = Environment.GetEnvironmentVariable("TEAMCITY_VERSION"); |
| 16 | + Console.WriteLine($"TEAMCITY_VERSION : {teamCityVersion}; IsBuildServer : {TestInfo.IsBuildServer}"); |
| 17 | + Assert.That(TestInfo.IsBuildServer, Is.EqualTo(teamCityVersion != null)); |
| 18 | + } |
| 19 | + |
| 20 | + [Test] |
| 21 | + public void IsGithubActionsTest() |
| 22 | + { |
| 23 | + var githubActions = Environment.GetEnvironmentVariable("GITHUB_WORKSPACE"); |
| 24 | + Console.WriteLine($"TEAMCITY_VERSION : {githubActions}; IsBuildServer : {TestInfo.IsGithubActions}"); |
| 25 | + |
| 26 | + if (githubActions is null) { |
| 27 | + Assert.That(TestInfo.IsGithubActions, Is.False); |
| 28 | + |
| 29 | + var githbuActionsNoIgnore = Environment.GetEnvironmentVariable("GA_NO_IGNORE"); |
| 30 | + Console.WriteLine($"GA_NO_IGNORE : {githbuActionsNoIgnore} ; NoIgnoreOnGithubActions : {TestInfo.NoIgnoreOnGithubActions}"); |
| 31 | + if (githbuActionsNoIgnore is null) |
| 32 | + Assert.That(TestInfo.NoIgnoreOnGithubActions); |
| 33 | + else |
| 34 | + Assert.That(TestInfo.NoIgnoreOnGithubActions); |
| 35 | + } |
| 36 | + else { |
| 37 | + Assert.That(TestInfo.IsGithubActions, Is.EqualTo(githubActions.Equals("true", StringComparison.OrdinalIgnoreCase))); |
| 38 | + if (githubActions.Equals("true", StringComparison.OrdinalIgnoreCase)) { |
| 39 | + |
| 40 | + var githubActionsTrigger = Environment.GetEnvironmentVariable("GITHUB_EVENT_NAME"); |
| 41 | + Console.WriteLine($"GITHUB_EVENT_NAME : {githubActionsTrigger} ; GithubActionTrigger : {TestInfo.GithubActionTrigger}"); |
| 42 | + if (githubActionsTrigger is null) { |
| 43 | + Assert.That(TestInfo.GithubActionTrigger.HasValue, Is.False); |
| 44 | + } |
| 45 | + else { |
| 46 | + Assert.That(TestInfo.GithubActionTrigger.HasValue, Is.True); |
| 47 | + } |
| 48 | + |
| 49 | + var githbuActionsNoIgnore = Environment.GetEnvironmentVariable("GA_NO_IGNORE"); |
| 50 | + Console.WriteLine($"GA_NO_IGNORE : {githbuActionsNoIgnore} ; NoIgnoreOnGithubActions : {TestInfo.NoIgnoreOnGithubActions}"); |
| 51 | + if (githbuActionsNoIgnore is null) { |
| 52 | + Assert.That(TestInfo.NoIgnoreOnGithubActions, Is.False); |
| 53 | + } |
| 54 | + else { |
| 55 | + Assert.That(TestInfo.NoIgnoreOnGithubActions, Is.EqualTo(githbuActionsNoIgnore.Equals("true", StringComparison.OrdinalIgnoreCase))); |
| 56 | + } |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | +} |
0 commit comments