@@ -9,6 +9,13 @@ import (
99 "github.com/stretchr/testify/require"
1010)
1111
12+ func validationErrAsError (err * ValidationError ) error {
13+ if err == nil {
14+ return nil
15+ }
16+ return err
17+ }
18+
1219func TestPortRange (t * testing.T ) {
1320 tests := []struct {
1421 name string
@@ -74,7 +81,7 @@ func TestPortRange(t *testing.T) {
7481 assert .Contains (t , err .Message , tt .errMsg , "Error message should contain expected text" )
7582 assert .Equal (t , tt .jsonPath , err .JSONPath , "JSONPath should match" )
7683 } else {
77- require .Nil (t , err , "Unexpected validation error" )
84+ require .NoError (t , validationErrAsError ( err ) , "Unexpected validation error" )
7885 }
7986 })
8087 }
@@ -138,7 +145,7 @@ func TestTimeoutPositive(t *testing.T) {
138145 assert .Equal (t , tt .jsonPath , err .JSONPath , "JSONPath should match" )
139146 assert .Equal (t , tt .fieldName , err .Field , "Field name should match" )
140147 } else {
141- require .Nil (t , err , "Unexpected validation error" )
148+ require .NoError (t , validationErrAsError ( err ) , "Unexpected validation error" )
142149 }
143150 })
144151 }
@@ -295,7 +302,7 @@ func TestMountFormat(t *testing.T) {
295302 assert .Contains (t , err .Message , tt .errMsg , "Error message should contain expected text" )
296303 assert .Equal (t , fmt .Sprintf ("%s.mounts[%d]" , tt .jsonPath , tt .index ), err .JSONPath , "JSONPath should match expected pattern" )
297304 } else {
298- require .Nil (t , err , "Unexpected validation error" )
305+ require .NoError (t , validationErrAsError ( err ) , "Unexpected validation error" )
299306 }
300307 })
301308 }
@@ -899,7 +906,7 @@ func TestNonEmptyString(t *testing.T) {
899906 assert .Contains (t , err .Error (), tt .errMsg )
900907 assert .Contains (t , err .Error (), tt .jsonPath )
901908 } else {
902- require .Nil (t , err , "Unexpected validation error" )
909+ require .NoError (t , validationErrAsError ( err ) , "Unexpected validation error" )
903910 }
904911 })
905912 }
@@ -1039,7 +1046,7 @@ func TestAbsolutePath(t *testing.T) {
10391046 assert .Contains (t , err .Error (), tt .errMsg )
10401047 assert .Contains (t , err .Error (), tt .jsonPath )
10411048 } else {
1042- require .Nil (t , err , "Unexpected validation error" )
1049+ require .NoError (t , validationErrAsError ( err ) , "Unexpected validation error" )
10431050 }
10441051 })
10451052 }
0 commit comments