fix: simplify else-if branches
This commit is contained in:
@@ -231,11 +231,9 @@ func TestValidateJWTSecret(t *testing.T) {
|
||||
if tt.errorMsg != "" && !strings.Contains(err.Error(), tt.errorMsg) {
|
||||
t.Fatalf("expected error message to contain %q, got %q", tt.errorMsg, err.Error())
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
} else if err != nil {
|
||||
t.Fatalf("unexpected error for secret %q: %v", tt.secret, err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -497,11 +495,9 @@ func TestValidateJWTConfig(t *testing.T) {
|
||||
if tt.errorMsg != "" && !strings.Contains(err.Error(), tt.errorMsg) {
|
||||
t.Fatalf("expected error message to contain %q, got %q", tt.errorMsg, err.Error())
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
} else if err != nil {
|
||||
t.Fatalf("unexpected error for config %+v: %v", tt.config, err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -626,11 +622,9 @@ func TestLoadWithInvalidJWTConfig(t *testing.T) {
|
||||
if tt.errorMsg != "" && !strings.Contains(err.Error(), tt.errorMsg) {
|
||||
t.Fatalf("expected error message to contain %q, got %q", tt.errorMsg, err.Error())
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
} else if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -912,11 +906,9 @@ func TestValidateBcryptCost(t *testing.T) {
|
||||
if tt.errorMsg != "" && !strings.Contains(err.Error(), tt.errorMsg) {
|
||||
t.Fatalf("expected error message to contain %q, got %q", tt.errorMsg, err.Error())
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
} else if err != nil {
|
||||
t.Fatalf("unexpected error for BCRYPT_COST %d: %v", tt.bcryptCost, err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -976,18 +968,15 @@ func TestLoadWithInvalidBcryptCost(t *testing.T) {
|
||||
if tt.errorMsg != "" && !strings.Contains(err.Error(), tt.errorMsg) {
|
||||
t.Fatalf("expected error message to contain %q, got %q", tt.errorMsg, err.Error())
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
} else if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
} else {
|
||||
expectedCost := 12
|
||||
if tt.bcryptCost == "" {
|
||||
expectedCost = 10
|
||||
} else {
|
||||
if costInt, err := strconv.Atoi(tt.bcryptCost); err == nil {
|
||||
} else if costInt, err := strconv.Atoi(tt.bcryptCost); err == nil {
|
||||
expectedCost = costInt
|
||||
}
|
||||
}
|
||||
if cfg.App.BcryptCost != expectedCost {
|
||||
t.Fatalf("expected BCRYPT_COST %d, got %d", expectedCost, cfg.App.BcryptCost)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user