File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -8,19 +8,19 @@ import (
88)
99
1010func TestNew (t * testing.T ) {
11+ // Create a box instance with a nil connection. This should lead to a panic later.
12+ b := box .New (nil )
13+
14+ // Ensure the box instance is not nil (which it shouldn't be), but this is not meaningful
15+ // since we will panic when we call the Info method with the nil connection.
16+ require .NotNil (t , b )
17+
1118 // We expect a panic because we are passing a nil connection (nil Doer) to the By function.
1219 // The library does not control this zone, and the nil connection would cause a runtime error
1320 // when we attempt to call methods (like Info) on it.
1421 // This test ensures that such an invalid state is correctly handled by causing a panic,
1522 // as it's outside the library's responsibility.
1623 require .Panics (t , func () {
17- // Create a box instance with a nil connection. This should lead to a panic later.
18- b := box .New (nil )
19-
20- // Ensure the box instance is not nil (which it shouldn't be), but this is not meaningful
21- // since we will panic when we call the Info method with the nil connection.
22- require .NotNil (t , b )
23-
2424 // Calling Info on a box with a nil connection will result in a panic, since the underlying
2525 // connection (Doer) cannot perform the requested action (it's nil).
2626 _ , _ = b .Info ()
You can’t perform that action at this time.
0 commit comments