Fix WorkloadIdentity.TTL handling, jobspec2 testing, and hcl1 vs 2 parsing (#19024)

* make the little dots consistent
* don't trim delimiter as that over matches
* test jobspec2 package
* copy api/WorkloadIdentity.TTL -> structs
* test ttl parsing
* fix hcl1 v 2 parsing mismatch
* make jobspec(1) tests match jobspec2 tests
This commit is contained in:
Michael Schurter
2023-11-08 09:01:16 -08:00
committed by GitHub
parent 9d075c44b2
commit c4ae91f8be
11 changed files with 34 additions and 15 deletions

View File

@@ -125,8 +125,8 @@ func isCoveredOne(p string, pkg string) bool {
}
if strings.HasSuffix(p, "/...") {
prefix := strings.TrimSuffix(p, "/...")
if strings.HasPrefix(pkg, prefix) {
prefix := strings.TrimSuffix(p, "...")
if strings.HasPrefix(pkg+"/", prefix) {
return true
}
}

View File

@@ -11,14 +11,17 @@ import (
func Test_isCoveredOne(t *testing.T) {
try := func(p string, exp bool) {
result := isCoveredOne(p, "foo/bar")
must.Eq(t, exp, result)
t.Run(p, func(t *testing.T) {
result := isCoveredOne(p, "foo/bar")
must.Eq(t, exp, result)
})
}
try("baz", false)
try("foo", false)
try("foo/bar/baz", false)
try("foo/bar", true)
try("foo/bar/...", true)
try("foo/b/...", false)
try("foo/...", true)
try("abc/...", false)
}