Skip to content

Commit 617ce92

Browse files
Copilotchrisw-dev
andcommitted
Refactor: Address code review feedback
- Extract duplicated boolean expression to variable for readability - Update misleading comment about default nil behavior Co-authored-by: chrisw-dev <[email protected]>
1 parent e19b2bf commit 617ce92

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

internal/handlers/config_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ func TestConfigHandler_UpdateErrorScenario(t *testing.T) {
345345
}
346346

347347
// Check the fields were stored correctly
348-
if scenario.Enabled != (tc.errorScenario.Enabled != nil && *tc.errorScenario.Enabled) {
349-
expectedEnabled := tc.errorScenario.Enabled != nil && *tc.errorScenario.Enabled
348+
expectedEnabled := tc.errorScenario.Enabled != nil && *tc.errorScenario.Enabled
349+
if scenario.Enabled != expectedEnabled {
350350
t.Errorf("wrong enabled status stored: got %v want %v", scenario.Enabled, expectedEnabled)
351351
}
352352
if scenario.Endpoint != tc.errorScenario.Endpoint {
@@ -489,11 +489,11 @@ func TestConfigHandler_ErrorScenarioDefaultEnabled(t *testing.T) {
489489
defaultUser := models.NewDefaultUser()
490490
handler := NewConfigHandler(mockStore, defaultUser)
491491

492-
// Test case where enabled field is not set (defaults to false in Go)
493-
// but should be enabled when endpoint and error are provided
492+
// Test case where enabled field is not set (nil pointer)
493+
// Should default to true when endpoint and error are provided
494494
configReq := ConfigRequest{
495495
ErrorScenario: &ErrorScenario{
496-
// Enabled field not set, defaults to false
496+
// Enabled field not set (nil), will default to true
497497
Endpoint: "authorize",
498498
Error: "unauthorized_client",
499499
ErrorDescription: "Client not authorized",

0 commit comments

Comments
 (0)