Relax errmsg check
@@ -17,6 +17,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "strings"
"testing"
"github.com/stretchr/testify/assert"
@@ -82,8 +83,7 @@ func TestInvalidPolicyPackTemplateName(t *testing.T) {
err := runNewPolicyPack(args)
assert.Error(t, err)
-
- assert.Contains(t, err.Error(), "not found")
+ assertNotFoundError(t, err)
})
t.Run("LocalTemplateNotFound", func(t *testing.T) {
@@ -102,7 +102,14 @@ func TestInvalidPolicyPackTemplateName(t *testing.T) {
err := runNewPolicyPack(args)
assert.Error(t, err)
-
- assert.Contains(t, err.Error(), "not found")
+ assertNotFoundError(t, err)
})
}
+
+func assertNotFoundError(t *testing.T, err error) {
+ msg := err.Error()
+ if strings.Contains(msg, "not found") || strings.Contains(msg, "no such file or directory") {
+ return
+ }
+ assert.Failf(t, "Error message does not contain \"not found\" or \"no such file or directory\": %s", msg)
+}
