@@ -2,6 +2,7 @@ package lib
22
33import (
44 "reflect"
5+ "strings"
56 "testing"
67)
78
@@ -36,8 +37,31 @@ func TestValidateWait(t *testing.T) {
3637 for _ , tt := range tests {
3738 t .Run (tt .name , func (t * testing.T ) {
3839 err := ValidateWait (tt .input )
39- if (err == nil && tt .expectedError != "" ) || (err != nil && err .Error () != tt .expectedError ) {
40- t .Errorf ("ValidateWait() error = %v, expectedError %v" , err , tt .expectedError )
40+ if tt .expectedError == "" {
41+ if err != nil {
42+ t .Errorf ("ValidateWait() error = %v, expectedError %v" , err , tt .expectedError )
43+ }
44+ } else {
45+ if err == nil {
46+ t .Errorf ("ValidateWait() error = nil, expectedError %v" , tt .expectedError )
47+ } else {
48+ expectedOptions := strings .Split (strings .TrimPrefix (tt .expectedError , "invalid wait option(s): " ), ", " )
49+ actualOptions := strings .Split (strings .TrimPrefix (err .Error (), "invalid wait option(s): " ), ", " )
50+
51+ expectedSet := make (map [string ]bool )
52+ actualSet := make (map [string ]bool )
53+
54+ for _ , opt := range expectedOptions {
55+ expectedSet [opt ] = true
56+ }
57+ for _ , opt := range actualOptions {
58+ actualSet [opt ] = true
59+ }
60+
61+ if ! reflect .DeepEqual (expectedSet , actualSet ) {
62+ t .Errorf ("ValidateWait() error options mismatch. Expected: %v, Got: %v" , expectedSet , actualSet )
63+ }
64+ }
4165 }
4266 })
4367 }
0 commit comments