From f8a6d3346614c81c87a6f75913cd03cf93ec8bc7 Mon Sep 17 00:00:00 2001 From: ashmrtn Date: Tue, 4 Oct 2022 12:41:41 -0700 Subject: [PATCH] Add test for idempotent repo creation (#1037) ## Description Regression test to ensure that hidden --succeed-if-exists flag works. ## Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [x] :robot: Test - [ ] :computer: CI/Deployment - [ ] :hamster: Trivial/Minor ## Issue(s) * #913 ## Test Plan - [ ] :muscle: Manual - [x] :zap: Unit test - [ ] :green_heart: E2E --- src/cli/repo/s3_integration_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/cli/repo/s3_integration_test.go b/src/cli/repo/s3_integration_test.go index 476a4fca7..2022fbd1c 100644 --- a/src/cli/repo/s3_integration_test.go +++ b/src/cli/repo/s3_integration_test.go @@ -79,6 +79,34 @@ func (suite *S3IntegrationSuite) TestInitS3Cmd() { } } +func (suite *S3IntegrationSuite) TestInitMultipleTimes() { + ctx := tester.NewContext() + t := suite.T() + + st := tester.NewPrefixedS3Storage(t) + cfg, err := st.S3Config() + require.NoError(t, err) + + vpr, configFP, err := tester.MakeTempTestConfigClone(t, nil) + require.NoError(t, err) + + ctx = config.SetViper(ctx, vpr) + + for i := 0; i < 2; i++ { + cmd := tester.StubRootCmd( + "repo", "init", "s3", + "--config-file", configFP, + "--bucket", cfg.Bucket, + "--prefix", cfg.Prefix, + "--succeed-if-exists", + ) + cli.BuildCommandTree(cmd) + + // run the command + require.NoError(t, cmd.ExecuteContext(ctx)) + } +} + func (suite *S3IntegrationSuite) TestInitS3Cmd_missingBucket() { ctx := tester.NewContext() t := suite.T()