2023-06-02 21:47:59 +02:00
using System ;
2022-09-26 10:17:46 +01:00
using System.Collections.Generic ;
using System.Linq ;
using GitHub.Runner.Worker ;
using Moq ;
using Xunit ;
namespace GitHub.Runner.Common.Tests.Worker
{
2023-06-29 12:52:05 +02:00
public sealed class SetOutputFileCommandL0 : FileCommandTestBase < SetOutputFileCommand >
2022-09-26 10:17:46 +01:00
{
2023-06-29 12:52:05 +02:00
protected override IDictionary < string , string > PostSetup ( )
{
var outputs = new Dictionary < string , string > ( ) ;
var reference = string . Empty ;
_executionContext . Setup ( x = > x . SetOutput ( It . IsAny < string > ( ) , It . IsAny < string > ( ) , out reference ) )
. Callback ( ( string name , string value , out string reference ) = >
{
reference = value ;
outputs [ name ] = value ;
} ) ;
return outputs ;
}
2022-09-26 10:17:46 +01:00
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_DirectoryNotFound ( )
{
2023-06-29 12:52:05 +02:00
base . TestDirectoryNotFound ( ) ;
2022-09-26 10:17:46 +01:00
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_NotFound ( )
{
2023-06-29 12:52:05 +02:00
base . TestNotFound ( ) ;
2022-09-26 10:17:46 +01:00
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_EmptyFile ( )
{
2023-06-29 12:52:05 +02:00
base . TestEmptyFile ( ) ;
2022-09-26 10:17:46 +01:00
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_Simple ( )
{
2023-06-29 12:52:05 +02:00
base . TestSimple ( ) ;
2022-09-26 10:17:46 +01:00
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_Simple_SkipEmptyLines ( )
{
2023-06-29 12:52:05 +02:00
base . TestSimple_SkipEmptyLines ( ) ;
2022-09-26 10:17:46 +01:00
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_Simple_EmptyValue ( )
{
2023-06-29 12:52:05 +02:00
base . TestSimple_EmptyValue ( ) ;
2022-09-26 10:17:46 +01:00
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_Simple_MultipleValues ( )
{
2023-06-29 12:52:05 +02:00
base . TestSimple_MultipleValues ( ) ;
2022-09-26 10:17:46 +01:00
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_Simple_SpecialCharacters ( )
{
2023-06-29 12:52:05 +02:00
base . TestSimple_SpecialCharacters ( ) ;
2022-09-26 10:17:46 +01:00
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_Heredoc ( )
{
2023-06-29 12:52:05 +02:00
base . TestHeredoc ( ) ;
2022-09-26 10:17:46 +01:00
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_Heredoc_EmptyValue ( )
{
2023-06-29 12:52:05 +02:00
base . TestHeredoc_EmptyValue ( ) ;
2022-09-26 10:17:46 +01:00
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_Heredoc_SkipEmptyLines ( )
{
2023-06-29 12:52:05 +02:00
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("<EOF")] [ InlineData ( "<<EOF" ) ] [ InlineData ( "EO<F" ) ] [ InlineData ( "EO<<F" ) ] [ InlineData ( "EOF<" ) ] [ InlineData ( "EOF<<" ) ]
[InlineData("+EOF")] [ InlineData ( "++EOF" ) ] [ InlineData ( "EO+F" ) ] [ InlineData ( "EO++F" ) ] [ InlineData ( "EOF+" ) ] [ InlineData ( "EOF++" ) ]
[InlineData("/EOF")] [ InlineData ( "//EOF" ) ] [ InlineData ( "EO/F" ) ] [ InlineData ( "EO//F" ) ] [ InlineData ( "EOF/" ) ] [ InlineData ( "EOF//" ) ]
#pragma warning restore format
[InlineData("<<//++==")]
[InlineData("contrivedBase64==")]
[InlineData("khkIhPxsVA==")]
[InlineData("D+Y8zE/EOw==")]
[InlineData("wuOWG4S6FQ==")]
[InlineData("7wigCJ//iw==")]
[InlineData("uifTuYTs8K4=")]
[InlineData("M7N2ITg/04c=")]
[InlineData("Xhh+qp+Y6iM=")]
[InlineData("5tdblQajc/b+EGBZXo0w")]
[InlineData("jk/UMjIx/N0eVcQYOUfw")]
[InlineData("/n5lsw73Cwl35Hfuscdz")]
[InlineData("ZvnAEW+9O0tXp3Fmb3Oh")]
public void SetOutputFileCommand_Heredoc_EndMarkerVariations ( string validEndMarker )
{
base . TestHeredoc_EndMarkerVariations ( validEndMarker ) ;
2022-09-26 10:17:46 +01:00
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
2023-06-29 12:52:05 +02:00
public void SetOutputFileCommand_Heredoc_EqualBeforeMultilineIndicator ( )
2022-09-26 10:17:46 +01:00
{
2023-06-29 12:52:05 +02:00
base . TestHeredoc_EqualBeforeMultilineIndicator ( ) ;
2022-09-26 10:17:46 +01:00
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_Heredoc_MissingNewLine ( )
{
2023-06-29 12:52:05 +02:00
base . TestHeredoc_MissingNewLine ( ) ;
2022-09-26 10:17:46 +01:00
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_Heredoc_MissingNewLineMultipleLines ( )
{
2023-06-29 12:52:05 +02:00
base . TestHeredoc_MissingNewLineMultipleLines ( ) ;
2022-09-26 10:17:46 +01:00
}
#if OS_WINDOWS
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetOutputFileCommand_Heredoc_PreservesNewline ( )
{
2023-06-29 12:52:05 +02:00
base . TestHeredoc_PreservesNewline ( ) ;
2022-09-26 10:17:46 +01:00
}
#endif
}
}