Skip to content

Commit

Permalink
test: add test to verify lifecycle.rule.condition.age_days = 0 (#1846)
Browse files Browse the repository at this point in the history
Zero (0) is a special value for some serialization configurations. Add a test to ensure it is properly passed to the backend, and is effective.
  • Loading branch information
BenWhitehead committed Jan 12, 2023
1 parent 45dc983 commit 3345ac9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,12 @@ private BucketInfo.LifecycleRule lifecycleRuleDecode(Bucket.Lifecycle.Rule from)
.collect(ImmutableList.toImmutableList());
conditionBuilder.setMatchesStorageClass(collect);
}
conditionBuilder.setMatchesPrefix(condition.getMatchesPrefixList());
conditionBuilder.setMatchesSuffix(condition.getMatchesSuffixList());
if (!condition.getMatchesPrefixList().isEmpty()) {
conditionBuilder.setMatchesPrefix(condition.getMatchesPrefixList());
}
if (!condition.getMatchesSuffixList().isEmpty()) {
conditionBuilder.setMatchesSuffix(condition.getMatchesSuffixList());
}
return new BucketInfo.LifecycleRule(lifecycleAction, conditionBuilder.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ public void deleteRule_addingALabelToABucketWithASingleDeleteRuleOnlyModifiesThe
}
}

@Test
public void condition_ageDays_0_shouldWork() throws Exception {
LifecycleRule d1 =
new LifecycleRule(
LifecycleAction.newAbortIncompleteMPUploadAction(),
LifecycleCondition.newBuilder().setAge(0).build());
BucketInfo info = baseInfo().setLifecycleRules(ImmutableList.of(d1)).build();

try (TemporaryBucket tmp =
TemporaryBucket.newBuilder().setBucketInfo(info).setStorage(storage).build()) {
BucketInfo bucket = tmp.getBucket();
Bucket update = storage.get(bucket.getName());
assertThat(update.getLifecycleRules()).isEqualTo(ImmutableList.of(d1));
}
}

@Test
public void deleteRule_modifyingLifecycleRulesMatchesLastOperation() throws Exception {
BucketInfo info;
Expand Down

0 comments on commit 3345ac9

Please sign in to comment.