From 04f0005f63a102a1462b343f963440b0ac67eeb5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 05:56:54 +0000 Subject: [PATCH 1/3] Initial plan From 8def271f072b67599789fb44491e8fc05805286f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 06:01:10 +0000 Subject: [PATCH 2/3] Initial plan: Modernize sliceutil tests to use testify assertions Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> --- .github/aw/actions-lock.json | 5 +++++ .github/workflows/slide-deck-maintainer.lock.yml | 2 +- .github/workflows/tidy.lock.yml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/aw/actions-lock.json b/.github/aw/actions-lock.json index 705bdeb0b6..b8a317833e 100644 --- a/.github/aw/actions-lock.json +++ b/.github/aw/actions-lock.json @@ -75,6 +75,11 @@ "version": "v4.8.0", "sha": "c1e323688fd81a25caa38c78aa6df2d33d3e20d9" }, + "actions/setup-node@v6": { + "repo": "actions/setup-node", + "version": "v6", + "sha": "6044e13b5dc448c55e2357c09f80417699197238" + }, "actions/setup-node@v6.1.0": { "repo": "actions/setup-node", "version": "v6.1.0", diff --git a/.github/workflows/slide-deck-maintainer.lock.yml b/.github/workflows/slide-deck-maintainer.lock.yml index 6ac360dc3b..86e5f70f6a 100644 --- a/.github/workflows/slide-deck-maintainer.lock.yml +++ b/.github/workflows/slide-deck-maintainer.lock.yml @@ -116,7 +116,7 @@ jobs: - name: Create gh-aw temp directory run: bash /opt/gh-aw/actions/create_gh_aw_tmp_dir.sh - name: Setup Node.js - uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 with: cache: npm cache-dependency-path: docs/package-lock.json diff --git a/.github/workflows/tidy.lock.yml b/.github/workflows/tidy.lock.yml index 36b50185e8..d859343685 100644 --- a/.github/workflows/tidy.lock.yml +++ b/.github/workflows/tidy.lock.yml @@ -143,7 +143,7 @@ jobs: - name: Create gh-aw temp directory run: bash /opt/gh-aw/actions/create_gh_aw_tmp_dir.sh - name: Setup Node.js - uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 with: cache: npm cache-dependency-path: actions/setup/js/package-lock.json From 6da4e97745a41c2b99d9af40129f243f601de31d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 06:05:40 +0000 Subject: [PATCH 3/3] Convert sliceutil tests to use testify assertions - Add testify/assert import statement - Convert all table-driven tests to use assert.Equal - Convert all edge case tests to use assert.True/False - Improve assertion messages for better test failure diagnostics - No functional changes - only assertion style updates Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> --- pkg/sliceutil/sliceutil_test.go | 95 +++++++++++---------------------- 1 file changed, 30 insertions(+), 65 deletions(-) diff --git a/pkg/sliceutil/sliceutil_test.go b/pkg/sliceutil/sliceutil_test.go index 5f89015733..37706b4c58 100644 --- a/pkg/sliceutil/sliceutil_test.go +++ b/pkg/sliceutil/sliceutil_test.go @@ -1,6 +1,10 @@ package sliceutil -import "testing" +import ( + "testing" + + "github.com/stretchr/testify/assert" +) func TestContains(t *testing.T) { tests := []struct { @@ -50,9 +54,8 @@ func TestContains(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { result := Contains(tt.slice, tt.item) - if result != tt.expected { - t.Errorf("Contains(%v, %q) = %v; want %v", tt.slice, tt.item, result, tt.expected) - } + assert.Equal(t, tt.expected, result, + "Contains should return correct value for slice %v and item %q", tt.slice, tt.item) }) } } @@ -117,9 +120,8 @@ func TestContainsAny(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { result := ContainsAny(tt.s, tt.substrings...) - if result != tt.expected { - t.Errorf("ContainsAny(%q, %v) = %v; want %v", tt.s, tt.substrings, result, tt.expected) - } + assert.Equal(t, tt.expected, result, + "ContainsAny should return correct value for string %q and substrings %v", tt.s, tt.substrings) }) } } @@ -184,9 +186,8 @@ func TestContainsIgnoreCase(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { result := ContainsIgnoreCase(tt.s, tt.substr) - if result != tt.expected { - t.Errorf("ContainsIgnoreCase(%q, %q) = %v; want %v", tt.s, tt.substr, result, tt.expected) - } + assert.Equal(t, tt.expected, result, + "ContainsIgnoreCase should return correct value for string %q and substring %q", tt.s, tt.substr) }) } } @@ -224,59 +225,40 @@ func TestContains_LargeSlice(t *testing.T) { } // Item at beginning - if !Contains(largeSlice, "a") { - t.Error("Expected to find 'a' at beginning of large slice") - } + assert.True(t, Contains(largeSlice, "a"), "should find 'a' at beginning of large slice") // Item at end - if !Contains(largeSlice, string(rune('a'+999%26))) { - t.Error("Expected to find item at end of large slice") - } + assert.True(t, Contains(largeSlice, string(rune('a'+999%26))), "should find item at end of large slice") // Item not in slice - if Contains(largeSlice, "not-present") { - t.Error("Expected not to find non-existent item in large slice") - } + assert.False(t, Contains(largeSlice, "not-present"), "should not find non-existent item in large slice") } func TestContains_SingleElement(t *testing.T) { slice := []string{"single"} - if !Contains(slice, "single") { - t.Error("Expected to find item in single-element slice") - } - - if Contains(slice, "other") { - t.Error("Expected not to find different item in single-element slice") - } + assert.True(t, Contains(slice, "single"), "should find item in single-element slice") + assert.False(t, Contains(slice, "other"), "should not find different item in single-element slice") } func TestContainsAny_MultipleMatches(t *testing.T) { s := "The quick brown fox jumps over the lazy dog" // Multiple substrings that match - if !ContainsAny(s, "quick", "lazy") { - t.Error("Expected to find at least one matching substring") - } + assert.True(t, ContainsAny(s, "quick", "lazy"), "should find at least one matching substring") // First one matches - if !ContainsAny(s, "quick", "missing", "absent") { - t.Error("Expected to find first matching substring") - } + assert.True(t, ContainsAny(s, "quick", "missing", "absent"), "should find first matching substring") // Last one matches - if !ContainsAny(s, "missing", "absent", "dog") { - t.Error("Expected to find last matching substring") - } + assert.True(t, ContainsAny(s, "missing", "absent", "dog"), "should find last matching substring") } func TestContainsAny_NilSubstrings(t *testing.T) { s := "test string" // Nil substrings should return false - if ContainsAny(s, nil...) { - t.Error("Expected false for nil substrings") - } + assert.False(t, ContainsAny(s, nil...), "should return false for nil substrings") } func TestContainsIgnoreCase_Unicode(t *testing.T) { @@ -315,9 +297,8 @@ func TestContainsIgnoreCase_Unicode(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { result := ContainsIgnoreCase(tt.s, tt.substr) - if result != tt.expected { - t.Errorf("ContainsIgnoreCase(%q, %q) = %v; want %v", tt.s, tt.substr, result, tt.expected) - } + assert.Equal(t, tt.expected, result, + "ContainsIgnoreCase should return correct value for string %q and substring %q", tt.s, tt.substr) }) } } @@ -326,26 +307,16 @@ func TestContainsIgnoreCase_PartialMatch(t *testing.T) { s := "GitHub Actions Workflow" // Should find partial matches - if !ContainsIgnoreCase(s, "hub") { - t.Error("Expected to find partial match 'hub' in 'GitHub'") - } - - if !ContainsIgnoreCase(s, "WORK") { - t.Error("Expected to find partial match 'WORK' in 'Workflow'") - } - - if !ContainsIgnoreCase(s, "actions workflow") { - t.Error("Expected to find multi-word partial match") - } + assert.True(t, ContainsIgnoreCase(s, "hub"), "should find partial match 'hub' in 'GitHub'") + assert.True(t, ContainsIgnoreCase(s, "WORK"), "should find partial match 'WORK' in 'Workflow'") + assert.True(t, ContainsIgnoreCase(s, "actions workflow"), "should find multi-word partial match") } func TestContains_Duplicates(t *testing.T) { // Slice with duplicate values slice := []string{"apple", "banana", "apple", "cherry", "apple"} - if !Contains(slice, "apple") { - t.Error("Expected to find 'apple' in slice with duplicates") - } + assert.True(t, Contains(slice, "apple"), "should find 'apple' in slice with duplicates") // Should still return true on first match count := 0 @@ -354,9 +325,7 @@ func TestContains_Duplicates(t *testing.T) { count++ } } - if count != 3 { - t.Errorf("Expected 3 occurrences of 'apple', got %d", count) - } + assert.Equal(t, 3, count, "should count all occurrences of duplicate item") } func TestContainsAny_OrderMatters(t *testing.T) { @@ -367,11 +336,7 @@ func TestContainsAny_OrderMatters(t *testing.T) { result1 := ContainsAny(s, "string", "words") result2 := ContainsAny(s, "words", "string") - if result1 != result2 { - t.Error("Expected same result regardless of substring order") - } - - if !result1 || !result2 { - t.Error("Expected both to find matches") - } + assert.Equal(t, result1, result2, "should return same result regardless of substring order") + assert.True(t, result1, "should find matches in first ordering") + assert.True(t, result2, "should find matches in second ordering") }