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