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 (
8
8
)
9
9
10
10
func 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
+
11
18
// We expect a panic because we are passing a nil connection (nil Doer) to the By function.
12
19
// The library does not control this zone, and the nil connection would cause a runtime error
13
20
// when we attempt to call methods (like Info) on it.
14
21
// This test ensures that such an invalid state is correctly handled by causing a panic,
15
22
// as it's outside the library's responsibility.
16
23
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
-
24
24
// Calling Info on a box with a nil connection will result in a panic, since the underlying
25
25
// connection (Doer) cannot perform the requested action (it's nil).
26
26
_ , _ = b .Info ()
You can’t perform that action at this time.
0 commit comments