Skip to content

Commit a042aa4

Browse files
committed
test(validator): assert the transport code positively, and state its reach
Adds the positive Unavailable assertion suggested in review: the negative alone would pass for any other verdict, including classification being lost entirely. Controlling it turned up something worth writing down rather than assuming. The assertion does not catch what the suggestion said it would. errors.Is walks the chain and Wrap keeps its Cause, so it matches when Unavailable is anywhere in the chain — replacing PropagateOrWrap with a plain Wrap to Internal still passes it. It pins the classification being dropped, not the outermost code being flattened while the inner error survives. Kept anyway: that is the same reach as the sibling TestEnsureTrainerInstalled_PreservesProbeErrorCode and the convention in this file, and dropped classification is the failure that actually matters here. Pinning the outermost code would need a type assertion rather than errors.Is, which is a change to the file's convention rather than to this test. The comment now says what the assertion pins instead of what it was hoped to. Refs #2297 Signed-off-by: Yuan Chen <yuanchen97@gmail.com>
1 parent a459df6 commit a042aa4

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

validators/performance/trainer_ensure_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,4 +507,17 @@ func TestWaitForDeclaredTrainer_TransportErrorKeepsItsClassification(t *testing.
507507
"is not a deployment that never completed, and swallowing that signal sends "+
508508
"the operator to fix the wrong thing", err)
509509
}
510+
// Assert the code positively, not only that it is not NotFound: the negative alone
511+
// would pass for any other verdict, including a total loss of classification.
512+
//
513+
// Note what this does and does not pin. errors.Is walks the chain and Wrap keeps its
514+
// Cause, so this matches when Unavailable is anywhere in the chain — it catches the
515+
// classification being dropped, not the outermost code being flattened while the
516+
// inner error survives. Verified by control: replacing PropagateOrWrap with a plain
517+
// Wrap to Internal still passes this. That is the same reach as the sibling
518+
// TestEnsureTrainerInstalled_PreservesProbeErrorCode, and the convention in this
519+
// file; pinning the outermost code would need a type assertion rather than errors.Is.
520+
if !stderrors.Is(err, aicrErrors.New(aicrErrors.ErrCodeUnavailable, "")) {
521+
t.Errorf("transport classification lost; want Unavailable, got: %v", err)
522+
}
510523
}

0 commit comments

Comments
 (0)