pkg/storage: fix partially initialized repo storage

Thanks shimish2 for the unit test.

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
This commit is contained in:
Ramkumar Chinchani
2021-08-09 23:08:55 +00:00
committed by Ramkumar Chinchani
parent 53b5fa6493
commit 63b88d0e57
2 changed files with 15 additions and 4 deletions
+15
View File
@@ -523,6 +523,21 @@ func TestNegativeCases(t *testing.T) {
err = il.InitRepo("test")
So(err, ShouldNotBeNil)
}
err = os.Chmod(dir, 0755)
So(err, ShouldBeNil)
// Init repo should fail if repo is a file.
err = ioutil.WriteFile(path.Join(dir, "file-test"), []byte("this is test file"), 0755) // nolint:gosec
So(err, ShouldBeNil)
err = il.InitRepo("file-test")
So(err, ShouldNotBeNil)
err = os.Mkdir(path.Join(dir, "test-dir"), 0755)
So(err, ShouldBeNil)
err = il.InitRepo("test-dir")
So(err, ShouldBeNil)
})
Convey("Invalid validate repo", t, func(c C) {