lifecycle: Assign unique id to rules with empty id (#15731)

This commit is contained in:
Krishnan Parthasarathi
2022-09-22 10:51:54 -07:00
committed by GitHub
parent 6e84283c66
commit 6f56ba80b3
4 changed files with 48 additions and 23 deletions
@@ -712,3 +712,32 @@ func TestMaxNoncurrentBackwardCompat(t *testing.T) {
}
}
}
func TestParseLifecycleConfigWithID(t *testing.T) {
r := bytes.NewReader([]byte(`<LifecycleConfiguration>
<Rule>
<ID>rule-1</ID>
<Filter>
<Prefix>prefix</Prefix>
</Filter>
<Status>Enabled</Status>
<Expiration><Days>3</Days></Expiration>
</Rule>
<Rule>
<Filter>
<Prefix>another-prefix</Prefix>
</Filter>
<Status>Enabled</Status>
<Expiration><Days>3</Days></Expiration>
</Rule>
</LifecycleConfiguration>`))
lc, err := ParseLifecycleConfigWithID(r)
if err != nil {
t.Fatalf("Expected parsing to succeed but failed with %v", err)
}
for _, rule := range lc.Rules {
if rule.ID == "" {
t.Fatalf("Expected all rules to have a unique id assigned %#v", rule)
}
}
}