updated the interface to return a Error struct and modified the function and tests accordingly

This commit is contained in:
AshwiniK-protean
2025-03-13 11:16:45 +05:30
parent 0488eccc3b
commit e9cc670e3d
8 changed files with 88 additions and 80 deletions

View File

@@ -12,8 +12,8 @@ import (
// MockValidator is a mock implementation of the Validator interface for testing.
type MockValidator struct{}
func (m *MockValidator) Validate(ctx context.Context, u url.URL, data []byte) (bool, error) {
return true, nil
func (m *MockValidator) Validate(ctx context.Context, u *url.URL, data []byte) (bool, definition.Error) {
return true, (definition.Error{})
}
// Mock New function for testing
@@ -70,7 +70,7 @@ func TestValidatorProvider_New(t *testing.T) {
// Check for expected error
if tt.expectedError != "" {
if err == nil || err.Error() != tt.expectedError {
if err == (definition.Error{}) || err.Message != tt.expectedError {
t.Errorf("expected error %q, got %v", tt.expectedError, err)
}
return