From b1d1bfb3b8725040f380967c2b957f80bcffe4b5 Mon Sep 17 00:00:00 2001 From: "devsy-app[bot]" <277138668+devsy-app[bot]@users.noreply.github.com> Date: Sat, 15 Aug 2026 10:26:48 +0000 Subject: [PATCH 1/5] test(provider): cover ParseOptions branches Add table-driven tests for ParseOptions in pkg/provider/parse.go, which previously had no test coverage despite being used by multiple client implementations. Covers empty input, value-with-equals preservation, key uppercasing and whitespace trimming, multiple-option collection, and rejection of options without an equals sign. --- pkg/provider/parse_options_test.go | 65 ++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 pkg/provider/parse_options_test.go diff --git a/pkg/provider/parse_options_test.go b/pkg/provider/parse_options_test.go new file mode 100644 index 000000000..479c0e143 --- /dev/null +++ b/pkg/provider/parse_options_test.go @@ -0,0 +1,65 @@ +package provider + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestParseOptions(t *testing.T) { + cases := []struct { + name string + options []string + want map[string]string + wantErr string + }{ + { + name: "empty input yields empty map", + options: []string{}, + want: map[string]string{}, + }, + { + name: "single key value", + options: []string{"FOO=bar"}, + want: map[string]string{"FOO": "bar"}, + }, + { + name: "value containing equals is preserved", + options: []string{"FOO=a=b"}, + want: map[string]string{"FOO": "a=b"}, + }, + { + name: "lowercase key is uppercased", + options: []string{"foo=bar"}, + want: map[string]string{"FOO": "bar"}, + }, + { + name: "surrounding whitespace around key is trimmed", + options: []string{" foo =bar"}, + want: map[string]string{"FOO": "bar"}, + }, + { + name: "multiple options are collected", + options: []string{"A=1", "B=two", "C="}, + want: map[string]string{"A": "1", "B": "two", "C": ""}, + }, + { + name: "option without equals is rejected", + options: []string{"FOO"}, + wantErr: `invalid option "FOO", expected format KEY=VALUE`, + }, + } + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + got, err := ParseOptions(tc.options) + if tc.wantErr != "" { + require.EqualError(t, err, tc.wantErr) + require.Nil(t, got) + return + } + require.NoError(t, err) + require.Equal(t, tc.want, got) + }) + } +} From 858e8f74df0b26390b76f10e5e18b840cdf907c9 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Mon, 17 Aug 2026 05:49:44 +0000 Subject: [PATCH 2/5] refactor: lint const errors Signed-off-by: Samuel K --- pkg/provider/parse_options_test.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/provider/parse_options_test.go b/pkg/provider/parse_options_test.go index 479c0e143..28efb0148 100644 --- a/pkg/provider/parse_options_test.go +++ b/pkg/provider/parse_options_test.go @@ -6,6 +6,8 @@ import ( "github.com/stretchr/testify/require" ) +const foo = "FOO" + func TestParseOptions(t *testing.T) { cases := []struct { name string @@ -21,22 +23,22 @@ func TestParseOptions(t *testing.T) { { name: "single key value", options: []string{"FOO=bar"}, - want: map[string]string{"FOO": "bar"}, + want: map[string]string{foo: "bar"}, }, { name: "value containing equals is preserved", options: []string{"FOO=a=b"}, - want: map[string]string{"FOO": "a=b"}, + want: map[string]string{foo: "a=b"}, }, { name: "lowercase key is uppercased", options: []string{"foo=bar"}, - want: map[string]string{"FOO": "bar"}, + want: map[string]string{foo: "bar"}, }, { name: "surrounding whitespace around key is trimmed", options: []string{" foo =bar"}, - want: map[string]string{"FOO": "bar"}, + want: map[string]string{foo: "bar"}, }, { name: "multiple options are collected", @@ -45,8 +47,8 @@ func TestParseOptions(t *testing.T) { }, { name: "option without equals is rejected", - options: []string{"FOO"}, - wantErr: `invalid option "FOO", expected format KEY=VALUE`, + options: []string{foo}, + wantErr: `invalid option foo, expected format KEY=VALUE`, }, } From b196003fa60862a5efbfc08380e9dc11850cd2f9 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Mon, 17 Aug 2026 07:00:18 +0000 Subject: [PATCH 3/5] style: update constants Signed-off-by: Samuel K --- pkg/provider/parse_options_test.go | 14 ++++++-------- pkg/provider/versions_testconst_test.go | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/provider/parse_options_test.go b/pkg/provider/parse_options_test.go index 28efb0148..96e910a38 100644 --- a/pkg/provider/parse_options_test.go +++ b/pkg/provider/parse_options_test.go @@ -6,8 +6,6 @@ import ( "github.com/stretchr/testify/require" ) -const foo = "FOO" - func TestParseOptions(t *testing.T) { cases := []struct { name string @@ -23,22 +21,22 @@ func TestParseOptions(t *testing.T) { { name: "single key value", options: []string{"FOO=bar"}, - want: map[string]string{foo: "bar"}, + want: map[string]string{testNameFoo: testNameBar}, }, { name: "value containing equals is preserved", options: []string{"FOO=a=b"}, - want: map[string]string{foo: "a=b"}, + want: map[string]string{testNameFoo: "a=b"}, }, { name: "lowercase key is uppercased", - options: []string{"foo=bar"}, - want: map[string]string{foo: "bar"}, + options: []string{"FOO=bar"}, + want: map[string]string{testNameFoo: testNameBar}, }, { name: "surrounding whitespace around key is trimmed", options: []string{" foo =bar"}, - want: map[string]string{foo: "bar"}, + want: map[string]string{testNameFoo: testNameBar}, }, { name: "multiple options are collected", @@ -47,7 +45,7 @@ func TestParseOptions(t *testing.T) { }, { name: "option without equals is rejected", - options: []string{foo}, + options: []string{testNameFoo}, wantErr: `invalid option foo, expected format KEY=VALUE`, }, } diff --git a/pkg/provider/versions_testconst_test.go b/pkg/provider/versions_testconst_test.go index 595f89ed0..1c8bd696e 100644 --- a/pkg/provider/versions_testconst_test.go +++ b/pkg/provider/versions_testconst_test.go @@ -5,4 +5,5 @@ const ( testTagV999 = "v9.9.9" testNameABC = "abc" testNameBar = "bar" + testNameFoo = "foo" ) From 23b9e4d6a87d9be89edf306815dd00b20cb6f9ff Mon Sep 17 00:00:00 2001 From: Samuel K Date: Mon, 17 Aug 2026 17:45:06 +0000 Subject: [PATCH 4/5] test: update content Signed-off-by: Samuel K --- pkg/provider/parse_options_test.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/provider/parse_options_test.go b/pkg/provider/parse_options_test.go index 96e910a38..0ec7835f9 100644 --- a/pkg/provider/parse_options_test.go +++ b/pkg/provider/parse_options_test.go @@ -1,6 +1,7 @@ package provider import ( + "strings" "testing" "github.com/stretchr/testify/require" @@ -20,23 +21,23 @@ func TestParseOptions(t *testing.T) { }, { name: "single key value", - options: []string{"FOO=bar"}, - want: map[string]string{testNameFoo: testNameBar}, + options: []string{"foo=bar"}, + want: map[string]string{strings.ToUpper(testNameFoo): testNameBar}, }, { name: "value containing equals is preserved", - options: []string{"FOO=a=b"}, - want: map[string]string{testNameFoo: "a=b"}, + options: []string{"foo=a=b"}, + want: map[string]string{strings.ToUpper(testNameFoo): "a=b"}, }, { name: "lowercase key is uppercased", - options: []string{"FOO=bar"}, - want: map[string]string{testNameFoo: testNameBar}, + options: []string{"foo=bar"}, + want: map[string]string{strings.ToUpper(testNameFoo): testNameBar}, }, { name: "surrounding whitespace around key is trimmed", options: []string{" foo =bar"}, - want: map[string]string{testNameFoo: testNameBar}, + want: map[string]string{strings.ToUpper(testNameFoo): testNameBar}, }, { name: "multiple options are collected", @@ -45,8 +46,8 @@ func TestParseOptions(t *testing.T) { }, { name: "option without equals is rejected", - options: []string{testNameFoo}, - wantErr: `invalid option foo, expected format KEY=VALUE`, + options: []string{strings.ToUpper(testNameFoo)}, + wantErr: `invalid option FOO, expected format KEY=VALUE`, }, } From 14d8ae18d706af2cbbb8821a71591d3676bf6148 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Mon, 17 Aug 2026 17:51:16 +0000 Subject: [PATCH 5/5] test(provider): fix expected error message quoting in ParseOptions test --- pkg/provider/parse_options_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/provider/parse_options_test.go b/pkg/provider/parse_options_test.go index 0ec7835f9..a5b5f8784 100644 --- a/pkg/provider/parse_options_test.go +++ b/pkg/provider/parse_options_test.go @@ -47,7 +47,7 @@ func TestParseOptions(t *testing.T) { { name: "option without equals is rejected", options: []string{strings.ToUpper(testNameFoo)}, - wantErr: `invalid option FOO, expected format KEY=VALUE`, + wantErr: `invalid option "FOO", expected format KEY=VALUE`, }, }