Skip to content

Commit

Permalink
fix runner expected-error check potential panic (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
4lisalehi authored Aug 23, 2023
1 parent b23cf19 commit ceb4bc9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions runner/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ func RunStage(runContext *TestRunContext, ftwCheck *check.FTWCheck, testCase tes
testInput := stage.Input
test.ApplyInputOverrides(&runContext.Config.TestOverride.Overrides, &testInput)
expectedOutput := stage.Output
expectErr := false
if expectedOutput.ExpectError != nil {
expectErr = *expectedOutput.ExpectError
}

// Check sanity first
if checkTestSanity(testInput) {
Expand All @@ -144,7 +148,7 @@ func RunStage(runContext *TestRunContext, ftwCheck *check.FTWCheck, testCase tes

if notRunningInCloudMode(ftwCheck) {
startMarker, err := markAndFlush(runContext, dest, stageID)
if err != nil && !*expectedOutput.ExpectError {
if err != nil && !expectErr {
return fmt.Errorf("failed to find start marker: %w", err)
}
ftwCheck.SetStartMarker(startMarker)
Expand All @@ -154,21 +158,21 @@ func RunStage(runContext *TestRunContext, ftwCheck *check.FTWCheck, testCase tes

err := runContext.Client.NewConnection(*dest)

if err != nil && !*expectedOutput.ExpectError {
if err != nil && !expectErr {
return fmt.Errorf("can't connect to destination %+v: %w", dest, err)
}
runContext.Client.StartTrackingTime()

response, responseErr := runContext.Client.Do(*req)

runContext.Client.StopTrackingTime()
if responseErr != nil && !*expectedOutput.ExpectError {
if responseErr != nil && !expectErr {
return fmt.Errorf("failed sending request to destination %+v: %w", dest, responseErr)
}

if notRunningInCloudMode(ftwCheck) {
endMarker, err := markAndFlush(runContext, dest, stageID)
if err != nil && !*expectedOutput.ExpectError {
if err != nil && !expectErr {
return fmt.Errorf("failed to find end marker: %w", err)

}
Expand Down

0 comments on commit ceb4bc9

Please sign in to comment.