File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -292,7 +292,7 @@ func runConftestTest() ([]jsonCheckResult, error) {
292
292
293
293
func getPolicyIDFromMetadata (metadata map [string ]interface {}, policyIDKey string ) (string , error ) {
294
294
details := metadata ["details" ].(map [string ]interface {})
295
- if details [policyIDKey ] == "" {
295
+ if details [policyIDKey ] == nil {
296
296
return "" , fmt .Errorf ("empty policyID key" )
297
297
}
298
298
Original file line number Diff line number Diff line change @@ -146,3 +146,16 @@ func TestGetPolicyIDFromMetadata(t *testing.T) {
146
146
t .Errorf ("output %v did not match expected %v" , actual , expected )
147
147
}
148
148
}
149
+
150
+ func TestGetPolicyIDFromMetadata_Empty (t * testing.T ) {
151
+ metadata := map [string ]interface {}{
152
+ "details" : map [string ]interface {}{
153
+ "test" : "TEST" ,
154
+ },
155
+ }
156
+
157
+ _ , err := getPolicyIDFromMetadata (metadata , "policyID" )
158
+ if err == nil {
159
+ t .Errorf ("should error when policyIDKey does not exist" )
160
+ }
161
+ }
You can’t perform that action at this time.
0 commit comments