(t *testing.T)
| 545 | } |
| 546 | |
| 547 | func (f *Fs) InternalTestLifecycleRules(t *testing.T) { |
| 548 | ctx := context.Background() |
| 549 | |
| 550 | opt := map[string]string{} |
| 551 | |
| 552 | t.Run("InitState", func(t *testing.T) { |
| 553 | // There should be no lifecycle rules at the outset |
| 554 | lifecycleRulesIf, err := f.lifecycleCommand(ctx, "lifecycle", nil, opt) |
| 555 | lifecycleRules := lifecycleRulesIf.([]api.LifecycleRule) |
| 556 | require.NoError(t, err) |
| 557 | assert.Equal(t, 0, len(lifecycleRules)) |
| 558 | }) |
| 559 | |
| 560 | t.Run("DryRun", func(t *testing.T) { |
| 561 | // There should still be no lifecycle rules after each dry run operation |
| 562 | ctx, ci := fs.AddConfig(ctx) |
| 563 | ci.DryRun = true |
| 564 | |
| 565 | opt["daysFromHidingToDeleting"] = "30" |
| 566 | lifecycleRulesIf, err := f.lifecycleCommand(ctx, "lifecycle", nil, opt) |
| 567 | lifecycleRules := lifecycleRulesIf.([]api.LifecycleRule) |
| 568 | require.NoError(t, err) |
| 569 | assert.Equal(t, 0, len(lifecycleRules)) |
| 570 | |
| 571 | delete(opt, "daysFromHidingToDeleting") |
| 572 | opt["daysFromUploadingToHiding"] = "40" |
| 573 | lifecycleRulesIf, err = f.lifecycleCommand(ctx, "lifecycle", nil, opt) |
| 574 | lifecycleRules = lifecycleRulesIf.([]api.LifecycleRule) |
| 575 | require.NoError(t, err) |
| 576 | assert.Equal(t, 0, len(lifecycleRules)) |
| 577 | |
| 578 | opt["daysFromHidingToDeleting"] = "30" |
| 579 | lifecycleRulesIf, err = f.lifecycleCommand(ctx, "lifecycle", nil, opt) |
| 580 | lifecycleRules = lifecycleRulesIf.([]api.LifecycleRule) |
| 581 | require.NoError(t, err) |
| 582 | assert.Equal(t, 0, len(lifecycleRules)) |
| 583 | }) |
| 584 | |
| 585 | t.Run("RealThing", func(t *testing.T) { |
| 586 | opt["daysFromHidingToDeleting"] = "30" |
| 587 | lifecycleRulesIf, err := f.lifecycleCommand(ctx, "lifecycle", nil, opt) |
| 588 | lifecycleRules := lifecycleRulesIf.([]api.LifecycleRule) |
| 589 | require.NoError(t, err) |
| 590 | assert.Equal(t, 1, len(lifecycleRules)) |
| 591 | assert.Equal(t, 30, *lifecycleRules[0].DaysFromHidingToDeleting) |
| 592 | |
| 593 | delete(opt, "daysFromHidingToDeleting") |
| 594 | opt["daysFromUploadingToHiding"] = "40" |
| 595 | lifecycleRulesIf, err = f.lifecycleCommand(ctx, "lifecycle", nil, opt) |
| 596 | lifecycleRules = lifecycleRulesIf.([]api.LifecycleRule) |
| 597 | require.NoError(t, err) |
| 598 | assert.Equal(t, 1, len(lifecycleRules)) |
| 599 | assert.Equal(t, 40, *lifecycleRules[0].DaysFromUploadingToHiding) |
| 600 | |
| 601 | opt["daysFromHidingToDeleting"] = "30" |
| 602 | lifecycleRulesIf, err = f.lifecycleCommand(ctx, "lifecycle", nil, opt) |
| 603 | lifecycleRules = lifecycleRulesIf.([]api.LifecycleRule) |
| 604 | require.NoError(t, err) |
nothing calls this directly
no test coverage detected