From 883bcd4ca986e3fae060f5a5a5880856ff73d327 Mon Sep 17 00:00:00 2001 From: Ilya Caramishev Date: Sat, 7 Mar 2026 10:44:10 +0200 Subject: [PATCH 1/2] Fix tests cases to use function params, not literals --- examples/panic/panic_test.go | 10 +++++----- examples/variadic/variadic_test.go | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/panic/panic_test.go b/examples/panic/panic_test.go index 821e952..9a1ff78 100644 --- a/examples/panic/panic_test.go +++ b/examples/panic/panic_test.go @@ -35,13 +35,13 @@ func TestSimulatePanicInDependency(t *testing.T) { // Override riskyOperation to panic Override(ctx, riskyOperation, Once, func(data []string, index int) string { - Expectation().CheckArgs([]string{"a", "b"}, 5) + Expectation().CheckArgs(data, index) panic("index out of bounds") })([]string{"a", "b"}, 5) // Override handlePanic to verify it's called with the right panic value Override(ctx, handlePanic, Once, func(r interface{}) error { - Expectation().CheckArgs("index out of bounds") + Expectation().CheckArgs(r) return ErrCritical })("index out of bounds") @@ -76,7 +76,7 @@ func TestRecoveryLogic(t *testing.T) { func TestValidationPanic(t *testing.T) { // Override validateInput to not panic, return error instead Override(TestingContext(t), validateInput, Once, func(value int) error { - Expectation().CheckArgs(-5) + Expectation().CheckArgs(value) // Instead of panicking, return an error return errors.New("negative values not allowed") })(-5) @@ -119,7 +119,7 @@ func TestQueryPanicPrevention(t *testing.T) { // Override Query to avoid panic Override(TestingContext(t), (*Database).Query, Once, func(db *Database, sql string) ([]string, error) { - Expectation().CheckArgs(db, "") + Expectation().CheckArgs(db, sql) // Return error gracefully instead of panicking return nil, fmt.Errorf("empty SQL not allowed") })(db, "") @@ -162,7 +162,7 @@ func TestSafeQueryWithPanicRecovery(t *testing.T) { func TestDivisionByZero(t *testing.T) { // Override DivideNumbers to not panic Override(TestingContext(t), DivideNumbers, Once, func(a, b float64) float64 { - Expectation().CheckArgs(10.0, 0.0) + Expectation().CheckArgs(a, b) // Handle gracefully - return zero or infinity return 0.0 })(10.0, 0.0) diff --git a/examples/variadic/variadic_test.go b/examples/variadic/variadic_test.go index 67e3d63..8b01a93 100644 --- a/examples/variadic/variadic_test.go +++ b/examples/variadic/variadic_test.go @@ -12,7 +12,7 @@ import ( func TestVariadicNoArgs(t *testing.T) { Override(TestingContext(t), formatList, Once, func(sep string, items ...string) string { // When checking args with variadic parameters, pass the variadic part as a slice - Expectation().CheckArgs(sep, []string{}) + Expectation().CheckArgs(sep, items) return "mocked-empty" })(", ") // Call with just the separator, no variadic args @@ -27,7 +27,7 @@ func TestVariadicNoArgs(t *testing.T) { // TestVariadicSingleArg tests overriding with a single variadic argument func TestVariadicSingleArg(t *testing.T) { Override(TestingContext(t), formatList, Once, func(sep string, items ...string) string { - Expectation().CheckArgs(sep, []string{"one"}) + Expectation().CheckArgs(sep, items) return "mocked-single" })(", ", "one") // Call with separator and one item @@ -42,7 +42,7 @@ func TestVariadicSingleArg(t *testing.T) { // TestVariadicMultipleArgs tests overriding with multiple variadic arguments func TestVariadicMultipleArgs(t *testing.T) { Override(TestingContext(t), formatList, Once, func(sep string, items ...string) string { - Expectation().CheckArgs(sep, []string{"alpha", "beta", "gamma"}) + Expectation().CheckArgs(sep, items) return "mocked-multiple" })(" | ", "alpha", "beta", "gamma") // Call with separator and multiple items @@ -61,7 +61,7 @@ func TestVariadicMethod(t *testing.T) { // For methods, receiver is first arg, then regular args, then variadic args individually Override(TestingContext(t), (*Logger).Log, Once, func(l *Logger, format string, args ...interface{}) string { - Expectation().CheckArgs(l, format, []interface{}{"REQ-123", 3}) + Expectation().CheckArgs(l, format, args) return "[TEST] mocked log" })(logger, "Processing request %s with %d parameters", "REQ-123", 3) @@ -76,7 +76,7 @@ func TestVariadicMethod(t *testing.T) { // TestStdlibVariadic tests overriding standard library variadic function func TestStdlibVariadic(t *testing.T) { Override(TestingContext(t), fmt.Sprintf, Once, func(format string, args ...interface{}) string { - Expectation().CheckArgs(format, []interface{}{"test", 42}) + Expectation().CheckArgs(format, args) return "mocked sprintf" })("Format: %s = %d", "test", 42) @@ -101,7 +101,7 @@ func TestProcessRequestSuccess(t *testing.T) { // Mock formatList to verify it's called correctly Override(ctx, formatList, Once, func(sep string, items ...string) string { - Expectation().CheckArgs(sep, []string{"param1", "param2", "param3"}) + Expectation().CheckArgs(sep, items) return "param1, param2, param3" })(", ", "param1", "param2", "param3") @@ -122,7 +122,7 @@ func TestVariadicErrorContext(t *testing.T) { // Test with no context Override(TestingContext(t), logError, Once, func(err error, context ...string) string { - Expectation().CheckArgs(err, []string{}) + Expectation().CheckArgs(err, context) return "mocked: no context" })(err) // No context args @@ -133,7 +133,7 @@ func TestVariadicErrorContext(t *testing.T) { // Test with single context item Override(TestingContext(t), logError, Once, func(err error, context ...string) string { - Expectation().CheckArgs(err, []string{"database"}) + Expectation().CheckArgs(err, context) return "mocked: single context" })(err, "database") // One context arg @@ -144,7 +144,7 @@ func TestVariadicErrorContext(t *testing.T) { // Test with multiple context items Override(TestingContext(t), logError, Once, func(err error, context ...string) string { - Expectation().CheckArgs(err, []string{"database", "user-service", "retry-3"}) + Expectation().CheckArgs(err, context) return "mocked: multiple context" })(err, "database", "user-service", "retry-3") // Multiple context args @@ -162,19 +162,19 @@ func TestVariadicChain(t *testing.T) { // First call - no items Override(ctx, formatList, Once, func(sep string, items ...string) string { - Expectation().CheckArgs(sep, []string{}) + Expectation().CheckArgs(sep, items) return "first" })(", ") // Second call - one item Override(ctx, formatList, Once, func(sep string, items ...string) string { - Expectation().CheckArgs(sep, []string{"item1"}) + Expectation().CheckArgs(sep, items) return "second" })(", ", "item1") // Third call - multiple items Override(ctx, formatList, Once, func(sep string, items ...string) string { - Expectation().CheckArgs(sep, []string{"a", "b", "c"}) + Expectation().CheckArgs(sep, items) return "third" })(", ", "a", "b", "c") From 9d66179eedfa6e67c913bd1b73851673d26a69da Mon Sep 17 00:00:00 2001 From: Ilya Caramishev Date: Sat, 7 Mar 2026 10:51:49 +0200 Subject: [PATCH 2/2] Build on macOS 26 --- .github/workflows/go.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 65b171d..02dcb03 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -18,9 +18,9 @@ jobs: arch: arm64 - os: windows-latest arch: amd64 - - os: macos-15-intel + - os: macos-26-intel arch: amd64 - - os: macos-15 + - os: macos-26 arch: arm64 steps: - uses: actions/checkout@v6