mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-25 04:49:05 +01:00
Start to integrate file based testing
This commit is contained in:
parent
5a09277d1c
commit
9299f65993
@ -4,22 +4,26 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
package repository_test
|
package repository_test
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"bytes"
|
||||||
|
"go/format"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
func TestHandleImportFlag(t *testing.T) {
|
func TestHandleImportFlag(t *testing.T) {
|
||||||
r := setupRepo(t)
|
r := setupRepo(t)
|
||||||
|
|
||||||
paths, err := filepath.Glob(filepath.Join("testdata", "*.input"))
|
tests, err := filepath.Glob(filepath.Join("testdata", "*.input"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range paths {
|
for _, path := range tests {
|
||||||
_, filename := filepath.Split(path)
|
_, filename := filepath.Split(path)
|
||||||
testname := filename[:len(filename)-len(filepath.Ext(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) {
|
t.Run(testname, func(t *testing.T) {
|
||||||
source, err := os.ReadFile(path)
|
source, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -47,10 +51,6 @@ func TestHandleImportFlag(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
s := "../../test/repo/meta1.json:../../test/repo/data1.json"
|
s := "../../test/repo/meta1.json:../../test/repo/data1.json"
|
||||||
err := HandleImportFlag(s)
|
err := HandleImportFlag(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user