migrate: add support for new Go io/fs.FS

This patch adds FromFS function and lets you use the new go:embed directive to add the migration files to the binary.
Also, migration tests use an in memory FS impl instead of working with tmp directories.
This commit is contained in:
Michał Matczuk
2021-04-29 18:19:32 +02:00
committed by Michal Jan Matczuk
parent 7980a955be
commit fe1498fe13
6 changed files with 73 additions and 107 deletions

View File

@@ -4,10 +4,13 @@
package migrate
import "testing"
import (
"os"
"testing"
)
func TestFileChecksum(t *testing.T) {
c, err := fileChecksum("testdata/file")
c, err := fileChecksum(os.DirFS("testdata"), "file")
if err != nil {
t.Fatal(err)
}