package smartconfig import ( "strings" "testing" ) // Helper functions for common test assertions func assertString(t *testing.T, got, want string) { t.Helper() if got != want { t.Errorf("got %q, want %q", got, want) } } func assertInt(t *testing.T, got, want int) { t.Helper() if got != want { t.Errorf("got %d, want %d", got, want) } } func assertFloat(t *testing.T, got, want float64) { t.Helper() if got != want { t.Errorf("got %f, want %f", got, want) } } func assertBool(t *testing.T, got, want bool) { t.Helper() if got != want { t.Errorf("got %v, want %v", got, want) } } func assertUint64(t *testing.T, got, want uint64) { t.Helper() if got != want { t.Errorf("got %d, want %d", got, want) } } func assertError(t *testing.T, err error) { t.Helper() if err == nil { t.Error("expected error, got nil") } } func assertNoError(t *testing.T, err error) { t.Helper() if err != nil { t.Errorf("unexpected error: %v", err) } } func assertExists(t *testing.T, exists bool) { t.Helper() if !exists { t.Error("expected to exist, but doesn't") } } func assertNotExists(t *testing.T, exists bool) { t.Helper() if exists { t.Error("expected not to exist, but does") } } func assertType[T any](t *testing.T, v interface{}) T { t.Helper() typed, ok := v.(T) if !ok { var zero T t.Errorf("expected type %T, got %T", zero, v) return zero } return typed } // loadConfig is a helper to load config from YAML string func loadConfig(t *testing.T, yamlContent string) *Config { t.Helper() config, err := NewFromReader(strings.NewReader(yamlContent)) if err != nil { t.Fatalf("Failed to load config: %v", err) } return config }