Relax errmsg check (#7482)

This commit is contained in:
Anton Tayanovskyy 2021-07-12 09:05:06 -04:00 committed by GitHub
parent e169844652
commit 83a249cf2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
}