init push
This commit is contained in:
33
internal/shared/pkg/apperrorsx/registry_test.go
Normal file
33
internal/shared/pkg/apperrorsx/registry_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package apperrorsx
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestRegistry_UniqueCodeAndErrorCode(t *testing.T) {
|
||||
seenCode := map[string]struct{}{}
|
||||
seenErrorCode := map[string]struct{}{}
|
||||
seenModuleCase := map[string]struct{}{}
|
||||
for _, d := range Registry {
|
||||
if d.Code == "" {
|
||||
t.Fatalf("empty code in registry: %#v", d)
|
||||
}
|
||||
if d.ErrorCode == "" {
|
||||
t.Fatalf("empty error_code in registry: %#v", d)
|
||||
}
|
||||
if _, ok := seenCode[d.Code]; ok {
|
||||
t.Fatalf("duplicate code: %s", d.Code)
|
||||
}
|
||||
if _, ok := seenErrorCode[d.ErrorCode]; ok {
|
||||
t.Fatalf("duplicate error_code: %s", d.ErrorCode)
|
||||
}
|
||||
if len(d.ErrorCode) != 7 {
|
||||
t.Fatalf("invalid error_code length for %s: %s", d.Code, d.ErrorCode)
|
||||
}
|
||||
moduleCase := d.ErrorCode[3:]
|
||||
if _, ok := seenModuleCase[moduleCase]; ok {
|
||||
t.Fatalf("duplicate module+case detected: %s (error_code=%s)", moduleCase, d.ErrorCode)
|
||||
}
|
||||
seenCode[d.Code] = struct{}{}
|
||||
seenErrorCode[d.ErrorCode] = struct{}{}
|
||||
seenModuleCase[moduleCase] = struct{}{}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user