Skip to content

Commit d2d50fa

Browse files
authored
only render exit code if tested (#65)
1 parent f9a034a commit d2d50fa

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Diff for: client/lessons.go

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ type CLICommandTestCase struct {
7070
ExitCode *int
7171
StdoutContainsAll []string
7272
StdoutContainsNone []string
73-
StdoutMatches *string
7473
StdoutLinesGt *int
7574
}
7675

Diff for: render/command.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ func (m cmdRootModel) View() string {
114114
str += renderTests(cmd.tests, s)
115115
if cmd.results != nil && m.finalized {
116116
// render the results
117-
str += fmt.Sprintf("\n > Command exit code: %d\n", cmd.results.ExitCode)
117+
for _, test := range cmd.tests {
118+
// for clarity, only show exit code if it's tested
119+
if strings.Contains(test.text, "exit code") {
120+
str += fmt.Sprintf("\n > Command exit code: %d\n", cmd.results.ExitCode)
121+
break
122+
}
123+
}
118124
str += " > Command stdout:\n\n"
119125
sliced := strings.Split(cmd.results.Stdout, "\n")
120126
for _, s := range sliced {
@@ -138,9 +144,6 @@ func prettyPrintCmd(test api.CLICommandTestCase) string {
138144
if test.StdoutLinesGt != nil {
139145
return fmt.Sprintf("Expect > %d lines on stdout", *test.StdoutLinesGt)
140146
}
141-
if test.StdoutMatches != nil {
142-
return fmt.Sprintf("Expect stdout to match '%s'", *test.StdoutMatches)
143-
}
144147
if test.StdoutContainsAll != nil {
145148
str := "Expect stdout to contain all of:"
146149
for _, thing := range test.StdoutContainsAll {

0 commit comments

Comments
 (0)