diff --git a/repo/fsrepo/migrations/fetch_test.go b/repo/fsrepo/migrations/fetch_test.go index f23729e3f22..0e7770c2c37 100644 --- a/repo/fsrepo/migrations/fetch_test.go +++ b/repo/fsrepo/migrations/fetch_test.go @@ -40,7 +40,7 @@ func TestHttpFetch(t *testing.T) { // Check bad URL url = gatewayURL + path.Join(ipfsDistPath, distFSRM, "no_such_file") - rc, err = httpFetch(ctx, url) + _, err = httpFetch(ctx, url) if err == nil || !strings.Contains(err.Error(), "404") { t.Fatal("expected error 404") } @@ -81,7 +81,7 @@ func TestIpfsFetch(t *testing.T) { // Check bad URL url = path.Join(ipfsDistPath, distFSRM, "no_such_file") - rc, err = ipfsFetch(ctx, url) + _, err = ipfsFetch(ctx, url) if err == nil || !strings.Contains(err.Error(), "no link") { t.Fatal("expected 'no link' error, got:", err) } diff --git a/repo/fsrepo/migrations/migrations.go b/repo/fsrepo/migrations/migrations.go index aa46dbc4182..8bccc78874a 100644 --- a/repo/fsrepo/migrations/migrations.go +++ b/repo/fsrepo/migrations/migrations.go @@ -14,8 +14,8 @@ import ( ) const ( - // Migrations distribution - distMigsRoot = "go-ipfs-repo-migrations" + // Migrations subdirectory in distribution. Empty for root (no subdir). + distMigsRoot = "" distFSRM = "fs-repo-migrations" ) diff --git a/repo/fsrepo/migrations/migrations_test.go b/repo/fsrepo/migrations/migrations_test.go index 27b45820027..e57093527df 100644 --- a/repo/fsrepo/migrations/migrations_test.go +++ b/repo/fsrepo/migrations/migrations_test.go @@ -3,8 +3,10 @@ package migrations import ( "context" "io/ioutil" + "net/http" "os" "path" + "strings" "testing" ) @@ -22,6 +24,9 @@ func TestFindMigrations(t *testing.T) { if err != nil { t.Fatal(err) } + if len(migs) != 5 { + t.Fatal("expected 5 migrations") + } if len(bins) != 0 { t.Fatal("should not have found migrations") } @@ -57,7 +62,16 @@ func TestFindMigrations(t *testing.T) { } func TestFetchMigrations(t *testing.T) { - t.Skip("skip - migrations not available on distribution site yet") + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + _, err := LatestDistVersion(ctx, "ipfs-1-to-2") + if err != nil { + if strings.Contains(err.Error(), http.StatusText(http.StatusNotFound)) { + t.Skip("skip - migrations not yet available on distribution site") + } + t.Fatal(err) + } tmpDir, err := ioutil.TempDir("", "migratetest") if err != nil { @@ -65,9 +79,6 @@ func TestFetchMigrations(t *testing.T) { } defer os.RemoveAll(tmpDir) - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - needed := []string{"ipfs-1-to-2", "ipfs-2-to-3"} fetched, err := fetchMigrations(ctx, needed, tmpDir) if err != nil { @@ -89,5 +100,8 @@ func createFakeBin(from, to int, tmpDir string) { panic(err) } emptyFile.Close() - os.Chmod(migPath, 0755) + err = os.Chmod(migPath, 0755) + if err != nil { + panic(err) + } }