| 1 | package migrations |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/restic/restic/internal/repository" |
| 8 | ) |
| 9 | |
| 10 | func TestUpgradeRepoV2(t *testing.T) { |
| 11 | repo, _, _ := repository.TestRepositoryWithVersion(t, 1) |
| 12 | if repo.Config().Version != 1 { |
| 13 | t.Fatal("test repo has wrong version") |
| 14 | } |
| 15 | |
| 16 | m := &UpgradeRepoV2{} |
| 17 | |
| 18 | ok, _, err := m.Check(context.Background(), repo) |
| 19 | if err != nil { |
| 20 | t.Fatal(err) |
| 21 | } |
| 22 | |
| 23 | if !ok { |
| 24 | t.Fatal("migration check returned false") |
| 25 | } |
| 26 | |
| 27 | err = m.Apply(context.Background(), repo) |
| 28 | if err != nil { |
| 29 | t.Fatal(err) |
| 30 | } |
| 31 | } |