fix(coloring): invalid color application for rows with VALID column (#3137)

* fix(coloring): invalid color application for rows with VALID column

Signed-off-by: aaronschweig <aaron.schweig@gmail.com>

* tests(pod): new valid function needs different test fixtures

Signed-off-by: aaronschweig <aaron.schweig@gmail.com>

* fix: fix tests without introducing a regression bug

Signed-off-by: aaronschweig <aaron.schweig@gmail.com>

---------

Signed-off-by: aaronschweig <aaron.schweig@gmail.com>
mine
Aaron Schweig 2025-03-12 06:36:46 +01:00 committed by GitHub
parent 772faa52fe
commit ee674d3706
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 50 additions and 1 deletions

View File

@ -50,7 +50,7 @@ func IsValid(ns string, h Header, r Row) bool {
return true
}
return strings.TrimSpace(r.Fields[idx]) == ""
return strings.TrimSpace(r.Fields[idx]) == "" || strings.ToLower(strings.TrimSpace(r.Fields[idx])) == "true"
}
func sortLabels(m map[string]string) (keys, vals []string) {

View File

@ -53,6 +53,55 @@ func TestLabelize(t *testing.T) {
}
}
func TestIsValid(t *testing.T) {
uu := map[string]struct {
ns string
h Header
r Row
e bool
}{
"empty": {
ns: "blee",
h: Header{},
r: Row{},
e: true,
},
"valid": {
ns: "blee",
h: Header{HeaderColumn{Name: "VALID"}},
r: Row{Fields: Fields{"true"}},
e: true,
},
"invalid": {
ns: "blee",
h: Header{HeaderColumn{Name: "VALID"}},
r: Row{Fields: Fields{"false"}},
e: false,
},
"valid_capital_case": {
ns: "blee",
h: Header{HeaderColumn{Name: "VALID"}},
r: Row{Fields: Fields{"True"}},
e: true,
},
"valid_all_caps": {
ns: "blee",
h: Header{HeaderColumn{Name: "VALID"}},
r: Row{Fields: Fields{"TRUE"}},
e: true,
},
}
for k, u := range uu {
t.Run(k, func(t *testing.T) {
valid := IsValid(u.ns, u.h, u.r)
assert.Equal(t, u.e, valid)
})
}
}
func TestDurationToSecond(t *testing.T) {
uu := map[string]struct {
s string