-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Laurent Goderre <[email protected]>
- Loading branch information
1 parent
185751b
commit 12e14c2
Showing
6 changed files
with
109 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package attestations | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestParse(t *testing.T) { | ||
for _, tc := range []struct { | ||
name string | ||
values map[string]string | ||
expected map[string]map[string]string | ||
}{ | ||
{ | ||
name: "simple", | ||
values: map[string]string{ | ||
"attest:sbom": "generator=docker.io/foo/bar", | ||
"attest:provenance": "mode=max", | ||
}, | ||
expected: map[string]map[string]string{ | ||
"sbom": { | ||
"generator": "docker.io/foo/bar", | ||
}, | ||
"provenance": { | ||
"mode": "max", | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "extra params", | ||
values: map[string]string{ | ||
"attest:sbom": "generator=docker.io/foo/bar,param1=foo,param2=bar", | ||
}, | ||
expected: map[string]map[string]string{ | ||
"sbom": { | ||
"generator": "docker.io/foo/bar", | ||
"param1": "foo", | ||
"param2": "bar", | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "extra params (complex)", | ||
values: map[string]string{ | ||
"attest:sbom": "\"generator=docker.io/foo/bar\",\"param1=foo\",\"param2=bar\",\"param3=abc,def\"", | ||
}, | ||
expected: map[string]map[string]string{ | ||
"sbom": { | ||
"generator": "docker.io/foo/bar", | ||
"param1": "foo", | ||
"param2": "bar", | ||
"param3": "abc,def", | ||
}, | ||
}, | ||
}, | ||
} { | ||
t.Run(tc.name, func(t *testing.T) { | ||
attests, err := Parse(tc.values) | ||
require.NoError(t, err) | ||
_ = attests | ||
assert.Equal(t, tc.expected, attests) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters