Skip to content

Commit 66efd37

Browse files
reyortiz3claude
andcommitted
Fix goconst and gci lint failures on main
Extract repeated string literals into named constants and fix import ordering to resolve all 50 goconst and 3 gci violations reported by golangci-lint. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bb8d690 commit 66efd37

32 files changed

Lines changed: 915 additions & 694 deletions

pkg/authz/authorizers/config_test.go

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ import (
1717
// testConfigType is a test configuration type registered for testing
1818
const testConfigType = "test-config-type"
1919

20+
// testConfigVersion and testConfigVersion2 are version strings used across config tests.
21+
const (
22+
testConfigVersion = "1.0"
23+
testConfigVersion2 = "2.0"
24+
)
25+
2026
// testFactory is a simple test factory for config tests
2127
type testFactory struct{}
2228

@@ -63,14 +69,14 @@ func TestConfigUnmarshalJSON(t *testing.T) {
6369
{
6470
name: "Valid configuration",
6571
input: `{"version": "1.0", "type": "test-config-type", "test_field": "value"}`,
66-
expectedVersion: "1.0",
72+
expectedVersion: testConfigVersion,
6773
expectedType: testConfigType,
6874
expectError: false,
6975
},
7076
{
7177
name: "Minimal configuration",
7278
input: `{"version": "2.0", "type": "customtype"}`,
73-
expectedVersion: "2.0",
79+
expectedVersion: testConfigVersion2,
7480
expectedType: "customtype",
7581
expectError: false,
7682
},
@@ -113,7 +119,7 @@ func TestConfigMarshalJSON(t *testing.T) {
113119
{
114120
name: "Config with raw config",
115121
config: Config{
116-
Version: "1.0",
122+
Version: testConfigVersion,
117123
Type: testConfigType,
118124
rawConfig: json.RawMessage(`{"version":"1.0","type":"test-config-type","test_field":"value"}`),
119125
},
@@ -122,7 +128,7 @@ func TestConfigMarshalJSON(t *testing.T) {
122128
{
123129
name: "Config without raw config (fallback)",
124130
config: Config{
125-
Version: "1.0",
131+
Version: testConfigVersion,
126132
Type: testConfigType,
127133
},
128134
expectError: false,
@@ -158,7 +164,7 @@ func TestConfigRawConfig(t *testing.T) {
158164

159165
rawData := json.RawMessage(`{"version":"1.0","type":"test-config-type"}`)
160166
config := Config{
161-
Version: "1.0",
167+
Version: testConfigVersion,
162168
Type: testConfigType,
163169
rawConfig: rawData,
164170
}
@@ -259,7 +265,7 @@ test_field: value`,
259265

260266
require.NoError(t, err)
261267
require.NotNil(t, config)
262-
assert.Equal(t, "1.0", config.Version)
268+
assert.Equal(t, testConfigVersion, config.Version)
263269
assert.Equal(t, ConfigType(testConfigType), config.Type)
264270
})
265271
}
@@ -333,7 +339,7 @@ func TestConfigValidate(t *testing.T) {
333339
{
334340
name: "Missing type",
335341
config: Config{
336-
Version: "1.0",
342+
Version: testConfigVersion,
337343
rawConfig: json.RawMessage(`{"version":"1.0"}`),
338344
},
339345
expectError: true,
@@ -342,7 +348,7 @@ func TestConfigValidate(t *testing.T) {
342348
{
343349
name: "Unsupported type",
344350
config: Config{
345-
Version: "1.0",
351+
Version: testConfigVersion,
346352
Type: "unsupported",
347353
rawConfig: json.RawMessage(`{"version":"1.0","type":"unsupported"}`),
348354
},
@@ -352,7 +358,7 @@ func TestConfigValidate(t *testing.T) {
352358
{
353359
name: "Missing raw config",
354360
config: Config{
355-
Version: "1.0",
361+
Version: testConfigVersion,
356362
Type: testConfigType,
357363
// No rawConfig
358364
},
@@ -362,7 +368,7 @@ func TestConfigValidate(t *testing.T) {
362368
{
363369
name: "Valid config",
364370
config: Config{
365-
Version: "1.0",
371+
Version: testConfigVersion,
366372
Type: testConfigType,
367373
rawConfig: json.RawMessage(`{"version":"1.0","type":"test-config-type","test_field":"value"}`),
368374
},
@@ -402,11 +408,11 @@ func TestNewConfig(t *testing.T) {
402408
{
403409
name: "Map config",
404410
fullConfig: map[string]interface{}{
405-
"version": "1.0",
411+
"version": testConfigVersion,
406412
"type": testConfigType,
407413
"test_field": "value",
408414
},
409-
expectedVersion: "1.0",
415+
expectedVersion: testConfigVersion,
410416
expectedType: testConfigType,
411417
},
412418
{
@@ -415,10 +421,10 @@ func TestNewConfig(t *testing.T) {
415421
Version string `json:"version"`
416422
Type string `json:"type"`
417423
}{
418-
Version: "2.0",
424+
Version: testConfigVersion2,
419425
Type: "testtype",
420426
},
421-
expectedVersion: "2.0",
427+
expectedVersion: testConfigVersion2,
422428
expectedType: "testtype",
423429
},
424430
}

0 commit comments

Comments
 (0)