Skip to content

Commit 30ad47c

Browse files
committed
test: update validation_test to use require
1 parent 1907d5a commit 30ad47c

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

provider/helpers/validation_test.go

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package helpers
22

33
import (
4-
"strings"
54
"testing"
5+
6+
"github.com/stretchr/testify/require"
67
)
78

89
func TestValidateURL(t *testing.T) {
@@ -137,27 +138,17 @@ func TestValidateURL(t *testing.T) {
137138
warnings, errors := ValidateURL(tt.value, tt.label)
138139

139140
if tt.expectError {
140-
if len(errors) == 0 {
141-
t.Errorf("expected an error but got none")
142-
return
143-
}
141+
require.NotEmpty(t, errors, "expected an error but got none")
144142

145143
if tt.errorContains != "" {
146-
errorStr := errors[0].Error()
147-
if !strings.Contains(errorStr, tt.errorContains) {
148-
t.Errorf("expected error to contain %q, got %q", tt.errorContains, errorStr)
149-
}
144+
require.Contains(t, errors[0].Error(), tt.errorContains)
150145
}
151146
} else {
152-
if len(errors) > 0 {
153-
t.Errorf("expected no errors but got: %v", errors)
154-
}
155-
156-
// Should always return nil for warnings
157-
if warnings != nil {
158-
t.Errorf("expected warnings to be nil, got %v", warnings)
159-
}
147+
require.Empty(t, errors, "expected no errors but got: %v", errors)
160148
}
149+
150+
// Should always return nil for warnings
151+
require.Nil(t, warnings, "expected warnings to be nil, got %v", warnings)
161152
})
162153
}
163154
}

0 commit comments

Comments
 (0)