Start to integrate file based testing

This commit is contained in:
Jan Eitzinger 2023-04-25 09:27:22 +02:00
parent 5a09277d1c
commit 9299f65993

View File

@ -4,22 +4,26 @@
// license that can be found in the LICENSE file.
package repository_test
import "testing"
import (
"bytes"
"go/format"
"os"
"path/filepath"
"testing"
)
func TestHandleImportFlag(t *testing.T) {
r := setupRepo(t)
paths, err := filepath.Glob(filepath.Join("testdata", "*.input"))
tests, err := filepath.Glob(filepath.Join("testdata", "*.input"))
if err != nil {
t.Fatal(err)
}
for _, path := range paths {
for _, path := range tests {
_, filename := filepath.Split(path)
testname := filename[:len(filename)-len(filepath.Ext(path))]
// Each path turns into a test: the test name is the filename without the
// extension.
t.Run(testname, func(t *testing.T) {
source, err := os.ReadFile(path)
if err != nil {
@ -47,10 +51,6 @@ func TestHandleImportFlag(t *testing.T) {
})
}
s := "../../test/repo/meta1.json:../../test/repo/data1.json"
err := HandleImportFlag(s)
if err != nil {