Skip to content

Commit e46880d

Browse files
committed
Add test commandlet + update test batch file
1 parent c86c954 commit e46880d

File tree

2 files changed

+35
-18
lines changed

2 files changed

+35
-18
lines changed

src/CLU/Microsoft.CLU.Test/PipelineAliasTest.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,18 @@ protected override void ProcessRecord()
9696
WriteObject(new TestRecord() { Name = $"Matched {RecordName}", Value = $"Matched {Value}", SomethingElse = $"Matched {SomethingElse}" });
9797
}
9898
}
99+
100+
[Cmdlet(VerbsCommon.Show, "TestRecordFromParameter")]
101+
public class ShowTestRecordFromParameter : PSCmdlet
102+
{
103+
104+
[Parameter(Mandatory = true, ValueFromPipeline = true)]
105+
[Alias("Rec")]
106+
public TestRecord Record { get; set; }
107+
108+
protected override void ProcessRecord()
109+
{
110+
WriteObject(Record);
111+
}
112+
}
99113
}
Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
SETLOCAL EnableExtensions
22

33
ECHO Test return code success case
4-
call azure success show
4+
call azure success show 2> out.error
55
REM We expect that the commands above succeed (return 0)
6-
IF ERRORLEVEL 1 (EXIT /B 1)
6+
IF %ERRORLEVEL% NEQ 0 (
7+
ECHO "Expected error level 0 for success, got " %ERRORLEVEL%
8+
EXIT /B 1
9+
)
710

811
ECHO Test return codes non terminating error case
9-
call azure success show --generatenonterminatingerror true
10-
if ERRORLEVEL 1 goto :verify_error_code_2
11-
REM We expect the error code to be 1 - so we shouldn't be here
12-
EXIT /B 1
13-
:verify_error_code_2
14-
IF ERRORLEVEL 2 (EXIT /B 1)
12+
call azure success show --generatenonterminatingerror true 2> out.error
13+
IF %ERRORLEVEL% NEQ 1 (
14+
ECHO "Expected error level 1 for non-terminating error, got " %ERRORLEVEL%
15+
EXIT /B 1
16+
)
1517

1618
ECHO Test return codes terminating error case
17-
call azure success show --generateterminatingerror true
18-
if ERRORLEVEL 2 goto :verify_error_code_3
19-
REM We expect the error code to be 1 - so we shouldn't be here
20-
EXIT /B 1
21-
:verify_error_code_3
22-
IF ERRORLEVEL 3 (EXIT /B 1)
19+
call azure success show --generateterminatingerror true 2> out.error
20+
IF %ERRORLEVEL% NEQ 2 (
21+
ECHO "Expected error level 2 for terminating error, got " %ERRORLEVEL%
22+
EXIT /B 1
23+
)
2324

2425
ECHO Test pipeline aliasing
25-
call azure test record new > testrecordnew.json
26-
call azure test record show < testrecordnew.json
26+
call azure test record new | azure test record show > out.txt
27+
IF %ERRORLEVEL% NEQ 0 (
28+
ECHO "Expected error level 0 for success, got " %ERRORLEVEL%
29+
EXIT /B 1
30+
)
2731

28-
REM We expect that the commands above succeed
29-
IF ERRORLEVEL 1 (EXIT /B 1)
3032

33+
ECHO ALL TESTS ARE HAPPY

0 commit comments

Comments
 (0)