Add test for optimize command with old indexes

This commit is contained in:
Alexander Neumann 2015-11-08 22:21:08 +01:00
parent c59b12c939
commit 2e6eee991d

View file

@ -699,16 +699,35 @@ func TestRebuildIndexAlwaysFull(t *testing.T) {
TestRebuildIndex(t) TestRebuildIndex(t)
} }
func TestOptimizeRemoveUnusedBlobs(t *testing.T) { var optimizeTests = []struct {
withTestEnvironment(t, func(env *testEnvironment, global GlobalOptions) { testFilename string
datafile := filepath.Join("..", "..", "checker", "testdata", "checker-test-repo.tar.gz") snapshotID string
SetupTarTestFixture(t, env.base, datafile) }{
{
// snapshotIDs := cmdList(t, global, "snapshots") filepath.Join("..", "..", "checker", "testdata", "checker-test-repo.tar.gz"),
// t.Logf("snapshots: %v", snapshotIDs) "a13c11e582b77a693dd75ab4e3a3ba96538a056594a4b9076e4cacebe6e06d43",
},
OK(t, os.Remove(filepath.Join(env.repo, "snapshots", "a13c11e582b77a693dd75ab4e3a3ba96538a056594a4b9076e4cacebe6e06d43"))) {
cmdOptimize(t, global) filepath.Join("..", "..", "repository", "testdata", "old-index-repo.tar.gz"),
cmdCheck(t, global) "",
}) },
}
func TestOptimizeRemoveUnusedBlobs(t *testing.T) {
for i, test := range optimizeTests {
withTestEnvironment(t, func(env *testEnvironment, global GlobalOptions) {
SetupTarTestFixture(t, env.base, test.testFilename)
if test.snapshotID != "" {
OK(t, os.Remove(filepath.Join(env.repo, "snapshots", test.snapshotID)))
}
cmdOptimize(t, global)
output := cmdCheckOutput(t, global)
if len(output) > 0 {
t.Errorf("expected no output for check in test %d, got:\n%v", i, output)
}
})
}
} }