using System; using System.Collections.Generic; using System.Linq; using GitHub.Runner.Worker; using Moq; using Xunit; namespace GitHub.Runner.Common.Tests.Worker { public sealed class SetOutputFileCommandL0 : FileCommandTestBase { protected override IDictionary PostSetup() { var outputs = new Dictionary(); var reference = string.Empty; _executionContext.Setup(x => x.SetOutput(It.IsAny(), It.IsAny(), out reference)) .Callback((string name, string value, out string reference) => { reference = value; outputs[name] = value; }); return outputs; } [Fact] [Trait("Level", "L0")] [Trait("Category", "Worker")] public void SetOutputFileCommand_DirectoryNotFound() { base.TestDirectoryNotFound(); } [Fact] [Trait("Level", "L0")] [Trait("Category", "Worker")] public void SetOutputFileCommand_NotFound() { base.TestNotFound(); } [Fact] [Trait("Level", "L0")] [Trait("Category", "Worker")] public void SetOutputFileCommand_EmptyFile() { base.TestEmptyFile(); } [Fact] [Trait("Level", "L0")] [Trait("Category", "Worker")] public void SetOutputFileCommand_Simple() { base.TestSimple(); } [Fact] [Trait("Level", "L0")] [Trait("Category", "Worker")] public void SetOutputFileCommand_Simple_SkipEmptyLines() { base.TestSimple_SkipEmptyLines(); } [Fact] [Trait("Level", "L0")] [Trait("Category", "Worker")] public void SetOutputFileCommand_Simple_EmptyValue() { base.TestSimple_EmptyValue(); } [Fact] [Trait("Level", "L0")] [Trait("Category", "Worker")] public void SetOutputFileCommand_Simple_MultipleValues() { base.TestSimple_MultipleValues(); } [Fact] [Trait("Level", "L0")] [Trait("Category", "Worker")] public void SetOutputFileCommand_Simple_SpecialCharacters() { base.TestSimple_SpecialCharacters(); } [Fact] [Trait("Level", "L0")] [Trait("Category", "Worker")] public void SetOutputFileCommand_Heredoc() { base.TestHeredoc(); } [Fact] [Trait("Level", "L0")] [Trait("Category", "Worker")] public void SetOutputFileCommand_Heredoc_EmptyValue() { base.TestHeredoc_EmptyValue(); } [Fact] [Trait("Level", "L0")] [Trait("Category", "Worker")] public void SetOutputFileCommand_Heredoc_SkipEmptyLines() { base.TestHeredoc_SkipEmptyLines(); } [Fact] [Trait("Level", "L0")] [Trait("Category", "Worker")] public void SetOutputFileCommand_Heredoc_EdgeCases() { base.TestHeredoc_EdgeCases(); } [Theory] [Trait("Level", "L0")] [Trait("Category", "Worker")] // All of the following are not only valid, but quite plausible end markers. // Most are derived straight from the example at https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings #pragma warning disable format [InlineData("=EOF")][InlineData("==EOF")][InlineData("EO=F")][InlineData("EO==F")][InlineData("EOF=")][InlineData("EOF==")] [InlineData("