2022-04-03 12:48:39 +00:00
|
|
|
package migrations
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/restic/restic/internal/repository"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestUpgradeRepoV2(t *testing.T) {
|
2022-12-11 09:41:22 +00:00
|
|
|
repo := repository.TestRepositoryWithVersion(t, 1)
|
2022-04-03 12:48:39 +00:00
|
|
|
if repo.Config().Version != 1 {
|
|
|
|
t.Fatal("test repo has wrong version")
|
|
|
|
}
|
|
|
|
|
|
|
|
m := &UpgradeRepoV2{}
|
|
|
|
|
2022-09-03 09:49:31 +00:00
|
|
|
ok, _, err := m.Check(context.Background(), repo)
|
2022-04-03 12:48:39 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
t.Fatal("migration check returned false")
|
|
|
|
}
|
|
|
|
|
|
|
|
err = m.Apply(context.Background(), repo)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|