noschema_error_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package engine
  2. import (
  3. "errors"
  4. "fmt"
  5. "testing"
  6. )
  7. func TestNoSchemaError(t *testing.T) {
  8. // Test creating a NoSchemaError
  9. err := NoSchemaError{Namespace: "test", Topic: "topic1"}
  10. expectedMsg := "topic test.topic1 has no schema"
  11. if err.Error() != expectedMsg {
  12. t.Errorf("Expected error message '%s', got '%s'", expectedMsg, err.Error())
  13. }
  14. // Test IsNoSchemaError with direct NoSchemaError
  15. if !IsNoSchemaError(err) {
  16. t.Error("IsNoSchemaError should return true for NoSchemaError")
  17. }
  18. // Test IsNoSchemaError with wrapped NoSchemaError
  19. wrappedErr := fmt.Errorf("wrapper: %w", err)
  20. if !IsNoSchemaError(wrappedErr) {
  21. t.Error("IsNoSchemaError should return true for wrapped NoSchemaError")
  22. }
  23. // Test IsNoSchemaError with different error type
  24. otherErr := errors.New("different error")
  25. if IsNoSchemaError(otherErr) {
  26. t.Error("IsNoSchemaError should return false for other error types")
  27. }
  28. // Test IsNoSchemaError with nil
  29. if IsNoSchemaError(nil) {
  30. t.Error("IsNoSchemaError should return false for nil")
  31. }
  32. }