@@ -11,10 +11,10 @@ import (
1111// TestNormalizeScopeKind tests all branches of NormalizeScopeKind.
1212func TestNormalizeScopeKind (t * testing.T ) {
1313 tests := []struct {
14- name string
15- input map [string ]interface {}
16- want map [string ]interface {}
17- isNil bool
14+ name string
15+ input map [string ]interface {}
16+ want map [string ]interface {}
17+ isNil bool
1818 }{
1919 {
2020 name : "nil input returns nil" ,
@@ -108,14 +108,14 @@ func TestGuardPolicyUnmarshalJSON_InvalidInnerJSON(t *testing.T) {
108108 wantErr : "invalid character" ,
109109 },
110110 {
111- name : "allow-only inner value is invalid JSON " ,
112- json : `{"allow-only": { not valid} }` ,
113- wantErr : "invalid character " ,
111+ name : "allow-only inner value fails AllowOnlyPolicy unmarshal " ,
112+ json : `{"allow-only": " not an object" }` ,
113+ wantErr : "cannot unmarshal string " ,
114114 },
115115 {
116- name : "write-sink inner value is invalid JSON " ,
117- json : `{"write-sink": { not valid} }` ,
118- wantErr : "invalid character " ,
116+ name : "write-sink inner value fails WriteSinkPolicy unmarshal " ,
117+ json : `{"write-sink": " not an object" }` ,
118+ wantErr : "cannot unmarshal string " ,
119119 },
120120 {
121121 name : "allow-only inner value fails AllowOnlyPolicy unmarshal - missing repos" ,
@@ -147,11 +147,6 @@ func TestAllowOnlyPolicyUnmarshalJSON_FieldErrorPaths(t *testing.T) {
147147 json string
148148 wantErr string
149149 }{
150- {
151- name : "repos field invalid JSON type" ,
152- json : `{"repos": {invalid}, "min-integrity": "none"}` ,
153- wantErr : "invalid character" ,
154- },
155150 {
156151 name : "min-integrity field invalid JSON type" ,
157152 json : `{"repos": "all", "min-integrity": [1,2,3]}` ,
@@ -434,6 +429,7 @@ func TestAllowOnlyPolicyUnmarshalJSON_FullRoundTrip(t *testing.T) {
434429 err = json .Unmarshal (data , parsed )
435430 require .NoError (t , err )
436431
432+ assert .Equal (t , original .Repos , parsed .Repos )
437433 assert .Equal (t , original .MinIntegrity , parsed .MinIntegrity )
438434 assert .Equal (t , original .BlockedUsers , parsed .BlockedUsers )
439435 assert .Equal (t , original .ApprovalLabels , parsed .ApprovalLabels )
0 commit comments