Add test for idempotent repo creation (#1037)

## Description

Regression test to ensure that hidden --succeed-if-exists flag works.

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [x] 🤖 Test
- [ ] 💻 CI/Deployment
- [ ] 🐹 Trivial/Minor

## Issue(s)

* #913 

## Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2022-10-04 12:41:41 -07:00 committed by GitHub
parent 67215c9bf1
commit f8a6d33466
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()