Make a proper check when checking for spaces. (#1206)

Mostly this covers tabs, but also other strange things, like carriage return :-)
This commit is contained in:
Victor Agababov 2020-04-08 13:31:02 -07:00 committed by GitHub
parent 83b38ce178
commit f384223ab1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import (
"io/ioutil"
"strings"
"testing"
"unicode"
"github.com/ghodss/yaml"
corev1 "k8s.io/api/core/v1"
@ -76,7 +77,7 @@ func ConfigMapsFromTestFile(t *testing.T, name string, allowed ...string) (*core
exampleBody := orig.Data[configmap.ExampleKey]
// Check that exampleBody does not have lines that end in a trailing space,
for i, line := range strings.Split(exampleBody, "\n") {
if strings.HasSuffix(line, " ") {
if strings.TrimRightFunc(line, unicode.IsSpace) != line {
t.Errorf("line %d of %q example contains trailing spaces", i, name)
}
}