@@ -13,16 +13,21 @@ func TestAttests(t *testing.T) {
13
13
attests := Attests {
14
14
{Type : "provenance" , Attrs : map [string ]string {"mode" : "max" }},
15
15
{Type : "sbom" , Disabled : true },
16
+ {Type : "sbom" , Attrs : map [string ]string {
17
+ "generator" : "scanner" ,
18
+ "ENV1" : `"foo,bar"` ,
19
+ "Env2" : "hello" ,
20
+ }},
16
21
}
17
22
18
- expected := `[{"type":"provenance","mode":"max"},{"type":"sbom","disabled":true}]`
23
+ expected := `[{"type":"provenance","mode":"max"},{"type":"sbom","disabled":true},{"ENV1":"\"foo,bar\"","Env2":"hello","generator":"scanner","type":"sbom"} ]`
19
24
actual , err := json .Marshal (attests )
20
25
require .NoError (t , err )
21
26
require .JSONEq (t , expected , string (actual ))
22
27
})
23
28
24
29
t .Run ("UnmarshalJSON" , func (t * testing.T ) {
25
- in := `[{"type":"provenance","mode":"max"},{"type":"sbom","disabled":true}]`
30
+ in := `[{"type":"provenance","mode":"max"},{"type":"sbom","disabled":true},{"ENV1":"\"foo,bar\"","Env2":"hello","generator":"scanner","type":"sbom"} ]`
26
31
27
32
var actual Attests
28
33
err := json .Unmarshal ([]byte (in ), & actual )
@@ -31,6 +36,11 @@ func TestAttests(t *testing.T) {
31
36
expected := Attests {
32
37
{Type : "provenance" , Attrs : map [string ]string {"mode" : "max" }},
33
38
{Type : "sbom" , Disabled : true , Attrs : map [string ]string {}},
39
+ {Type : "sbom" , Disabled : false , Attrs : map [string ]string {
40
+ "generator" : "scanner" ,
41
+ "ENV1" : `"foo,bar"` ,
42
+ "Env2" : "hello" ,
43
+ }},
34
44
}
35
45
require .Equal (t , expected , actual )
36
46
})
0 commit comments