From 6755e4020c1b4c64627daa1cc1ac3164ad377e38 Mon Sep 17 00:00:00 2001 From: aoright <102943475+aoright@users.noreply.github.com> Date: Wed, 19 Aug 2026 15:43:16 +0800 Subject: [PATCH] test: add TestOptionsApply and TestRunOnFailure in options_test.go Signed-off-by: aoright <102943475+aoright@users.noreply.github.com> --- options_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/options_test.go b/options_test.go index fd7751e..53cca40 100644 --- a/options_test.go +++ b/options_test.go @@ -122,3 +122,31 @@ func TestOptionsRetry(t *testing.T) { assert.False(t, opts.retry(51), "Attempt 51/51 should not allow retrying") assert.False(t, opts.retry(52), "Attempt 52/51 should not allow retrying") } + +func TestOptionsApply(t *testing.T) { + var cleaned bool + cleanupFn := func(int) { cleaned = true } + + o := &opts{ + maxRetries: 10, + maxSleep: time.Second, + cleanup: cleanupFn, + runOnFailure: true, + } + + target := &opts{} + o.apply(target) + + assert.Equal(t, 10, target.maxRetries) + assert.Equal(t, time.Second, target.maxSleep) + assert.True(t, target.runOnFailure) + assert.NotNil(t, target.cleanup) + target.cleanup(0) + assert.True(t, cleaned) +} + +func TestRunOnFailure(t *testing.T) { + opts := buildOpts(RunOnFailure()) + assert.True(t, opts.runOnFailure) +} +