actor/test: extend TestAwaitFuture to cover fn.Err result path
What changed, and why it matters
This commit only adds a new test case to an existing unit test. It checks that a helper function correctly returns an error when a future/promise is completed with an error value. There are no changes to production code, no bug fixes, and no security-relevant behavior changes.
No action needed. This is a benign test-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change extends TestAwaitFuture in actor/future_test.go to cover the fn.Err result path of AwaitFuture. It adds a test scenario where a Promise[string] is completed with fn.Errstring, and asserts that AwaitFuture returns the zero string value and the sentinel error. This is purely a test-coverage improvement; no implementation code was modified.
Changed components
actor/future_test.goInspect captured patch +12 / −1
diff --git a/actor/future_test.go b/actor/future_test.go
index 45d6314..519f0d4 100644
--- a/actor/future_test.go
+++ b/actor/future_test.go
@@ -458,7 +458,8 @@ func TestCompleteWith(t *testing.T) {
}
// TestAwaitFuture verifies that AwaitFuture unpacks a resolved future into a
-// (value, nil) pair and that context cancellation before resolution is
+// (value, nil) pair, that a future completed with fn.Err is reported as a
+// (zero, err) pair, and that context cancellation before resolution is
// reported as a (zero, ctx.Err()) pair.
func TestAwaitFuture(t *testing.T) {
t.Parallel()
@@ -471,6 +472,16 @@ func TestAwaitFuture(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "hello", val)
+ // Future completed with fn.Err — should surface the error as the
+ // second return value with the zero string value.
+ sentinel := fmt.Errorf("result-level error")
+ errPromise := NewPromise[string]()
+ errPromise.Complete(fn.Err[string](sentinel))
+
+ val3, err3 := AwaitFuture(context.Background(), errPromise.Future())
+ require.ErrorIs(t, err3, sentinel)
+ require.Equal(t, "", val3, "zero value expected on fn.Err result")
+
// Cancelled context — should return the zero value and ctx.Err().
unresolved := NewPromise[string]()
ctx, cancel := context.WithCancel(context.Background())
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.