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 Xunit ;
namespace GitHub.Runner.Common.Tests.Worker
{
2023-06-29 12:52:05 +02:00
public sealed class SaveStateFileCommandL0 : FileCommandTestBase < SaveStateFileCommand >
2022-09-26 10:17:46 +01:00
{
2023-06-29 12:52:05 +02:00
protected override IDictionary < string , string > PostSetup ( )
{
var intraActionState = new Dictionary < string , string > ( ) ;
_executionContext . Setup ( x = > x . IntraActionState ) . Returns ( intraActionState ) ;
return intraActionState ;
}
2022-09-26 10:17:46 +01:00
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SaveStateFileCommand_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 SaveStateFileCommand_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 SaveStateFileCommand_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 SaveStateFileCommand_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 SaveStateFileCommand_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 SaveStateFileCommand_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 SaveStateFileCommand_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 SaveStateFileCommand_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 SaveStateFileCommand_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 SaveStateFileCommand_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 SaveStateFileCommand_Heredoc_SkipEmptyLines ( )
{
2023-06-29 12:52:05 +02:00
base . TestHeredoc_SkipEmptyLines ( ) ;
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SaveStateFileCommand_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 SaveStateFileCommand_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 SaveStateFileCommand_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 SaveStateFileCommand_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 SaveStateFileCommand_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 SaveStateFileCommand_Heredoc_PreservesNewline ( )
{
2023-06-29 12:52:05 +02:00
base . TestHeredoc_PreservesNewline ( ) ;
2022-09-26 10:17:46 +01:00
}
#endif
}
}