mirror of
https://github.com/strongdm/comply
synced 2025-12-06 06:14:09 +00:00
Update pandoc dockerfile and latex template and fix infinite build, fix pandoc always pull and fix strikethrough (#100, #103 and #115)
This commit is contained in:
52
internal/util/test_utils.go
Normal file
52
internal/util/test_utils.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/strongdm/comply/internal/config"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
type TestFixture func()
|
||||
|
||||
func ExecuteTests(t *testing.T, testGroupType reflect.Type, beforeEach TestFixture, afterEach TestFixture) {
|
||||
testGroup := reflect.New(testGroupType).Elem().Interface()
|
||||
for i := 0; i < testGroupType.NumMethod(); i++ {
|
||||
m := testGroupType.Method(i)
|
||||
t.Run(m.Name, func(t *testing.T) {
|
||||
if beforeEach != nil {
|
||||
beforeEach()
|
||||
}
|
||||
|
||||
in := []reflect.Value{reflect.ValueOf(testGroup), reflect.ValueOf(t)}
|
||||
m.Func.Call(in)
|
||||
|
||||
if afterEach != nil {
|
||||
afterEach()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func MockConfig() {
|
||||
config.Config = func() *config.Project {
|
||||
p := config.Project{}
|
||||
cfgBytes, _ := ioutil.ReadFile(filepath.Join(GetRootPath(), "comply.yml.example"))
|
||||
err := yaml.Unmarshal(cfgBytes, &p)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return &p
|
||||
}
|
||||
}
|
||||
|
||||
func GetRootPath() string {
|
||||
_, fileName, _, _ := runtime.Caller(0)
|
||||
fileDir := filepath.Dir(fileName)
|
||||
return fmt.Sprintf("%s/../../example", fileDir)
|
||||
}
|
||||
Reference in New Issue
Block a user