refactor(config): improve sync config with warnings toggle and dedup
Code review improvements to internal/config/sync.go: 1. Warning suppression toggle - Add ConfigWarnings bool to enable/disable warnings - Add ConfigWarningWriter io.Writer for testable output 2. Consolidate sync mode constants - cmd/bd/sync_mode.go now imports from internal/config - Single source of truth for mode values - Uses shared IsValidSyncMode() for validation 3. Fix empty sovereignty semantics - Empty now returns SovereigntyNone (no restriction) - Only non-empty invalid values fall back to T1 with warning 4. Export validation helpers - IsValidSyncMode(), IsValidConflictStrategy(), IsValidSovereignty() - ValidSyncModes(), ValidConflictStrategies(), ValidSovereigntyTiers() - String() methods on all typed values 5. Logger interface - ConfigWarningWriter allows custom logging destinations - Tests can capture warnings without os.Stderr manipulation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1124,9 +1124,9 @@ func TestFederationConfigDefaults(t *testing.T) {
|
||||
if cfg.Remote != "" {
|
||||
t.Errorf("GetFederationConfig().Remote = %q, want empty", cfg.Remote)
|
||||
}
|
||||
// Default sovereignty is T1 when not configured
|
||||
if cfg.Sovereignty != SovereigntyT1 {
|
||||
t.Errorf("GetFederationConfig().Sovereignty = %q, want %q (default)", cfg.Sovereignty, SovereigntyT1)
|
||||
// Default sovereignty is empty (no restriction) when not configured
|
||||
if cfg.Sovereignty != SovereigntyNone {
|
||||
t.Errorf("GetFederationConfig().Sovereignty = %q, want %q (no restriction)", cfg.Sovereignty, SovereigntyNone)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user