Skip to content

Commit 8b09dec

Browse files
further test cleanup
1 parent 99745a5 commit 8b09dec

3 files changed

Lines changed: 6 additions & 43 deletions

File tree

checks/cli_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func TestRunCLICommandInterpolatesCapturedStdoutVariables(t *testing.T) {
122122
}
123123
}
124124

125-
func TestParseStdoutVariablesUsesGenericConfigurationError(t *testing.T) {
125+
func TestParseStdoutVariablesRejectsInvalidConfiguration(t *testing.T) {
126126
tests := []struct {
127127
name string
128128
vardef api.CLICommandStdoutVariable
@@ -152,9 +152,6 @@ func TestParseStdoutVariablesUsesGenericConfigurationError(t *testing.T) {
152152
if err == nil {
153153
t.Fatal("expected parse error")
154154
}
155-
if err.Error() != "invalid stdout variable configuration" {
156-
t.Fatalf("error = %q, want invalid stdout variable configuration", err.Error())
157-
}
158155
})
159156
}
160157
}

checks/local_test.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,6 @@ func TestEvaluateCLICommandReportsExecutionError(t *testing.T) {
9393
}
9494
}
9595

96-
func TestEvaluateStdoutJq(t *testing.T) {
97-
err := evaluateStdoutJq(
98-
"{\"ok\":true}",
99-
api.StdoutJqTest{
100-
InputMode: "json",
101-
Query: ".ok",
102-
ExpectedResults: []api.JqExpectedResult{
103-
{Type: api.JqTypeBool, Operator: "==", Value: true},
104-
},
105-
},
106-
map[string]string{},
107-
)
108-
if err != nil {
109-
t.Fatalf("unexpected jq failure: %v", err)
110-
}
111-
}
112-
11396
func TestEvaluateStdoutJqNumericComparisons(t *testing.T) {
11497
for _, tt := range []struct {
11598
operator api.JqOperator
@@ -360,6 +343,7 @@ func TestEvaluateStdoutJqResultTypes(t *testing.T) {
360343
{"fractional expected", "6", api.JqTypeInt, ">", 5.5, false},
361344
{"exact large integer", "9007199254740992", api.JqTypeInt, "==", json.Number("9007199254740993"), false},
362345
{"out of range float", "0", api.JqTypeInt, "<=", -float64(math.MinInt), false},
346+
{"boolean", "true", api.JqTypeBool, "==", true, true},
363347
{"boolean strings", `"true"`, api.JqTypeBool, "==", "true", true},
364348
{"invalid boolean", `"yes"`, api.JqTypeBool, "==", true, false},
365349
{"interpolated string", `"5"`, api.JqTypeString, "==", "${value}", true},

cmd/localtest_test.go

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,9 @@ import (
1111

1212
func TestReadLocalCLIDataAcceptsLessonDirectory(t *testing.T) {
1313
dir := t.TempDir()
14-
manifest := []byte(`allowedOperatingSystems:
15-
- linux
16-
- darwin
17-
baseURLDefault: http://localhost:3000
18-
steps:
19-
- description: Prints a greeting
20-
cliCommand:
14+
manifest := []byte(`steps:
15+
- cliCommand:
2116
command: echo hello
22-
tests:
23-
- exitCode: 0
24-
- stdoutContainsAll:
25-
- hello
2617
`)
2718
if err := os.WriteFile(filepath.Join(dir, "cli.yaml"), manifest, 0o600); err != nil {
2819
t.Fatalf("failed to write test manifest: %v", err)
@@ -32,17 +23,8 @@ steps:
3223
if err != nil {
3324
t.Fatalf("readLocalCLIData() error = %v", err)
3425
}
35-
if data.BaseURLDefault != "http://localhost:3000" {
36-
t.Fatalf("BaseURLDefault = %q, want localhost default", data.BaseURLDefault)
37-
}
38-
if len(data.Steps) != 1 || data.Steps[0].CLICommand == nil {
39-
t.Fatalf("expected one CLI command step, got %#v", data.Steps)
40-
}
41-
if data.Steps[0].Description != "Prints a greeting" {
42-
t.Fatalf("Description = %q, want manifest description", data.Steps[0].Description)
43-
}
44-
if len(data.Steps[0].CLICommand.Tests[1].StdoutContainsAll) != 1 {
45-
t.Fatalf("expected stdoutContainsAll test to load")
26+
if len(data.Steps) != 1 || data.Steps[0].CLICommand == nil || data.Steps[0].CLICommand.Command != "echo hello" {
27+
t.Fatalf("expected one command loaded from cli.yaml, got %#v", data.Steps)
4628
}
4729
}
4830

0 commit comments

Comments
 (0)