package mjs import ( "fmt" "io/ioutil" "log" "os" "testing" ) var contentPath = "content" func filePath(name string) string { return fmt.Sprintf("%v/%v", contentPath, name) } func modified(name string) (res int64) { if info, err := os.Stat(filePath(name)); err == nil { res = info.ModTime().Unix() } return } func content(name string) ([]byte, error) { return ioutil.ReadFile(filePath(name)) } func TestMJS(t *testing.T) { mjs := New(modified, content) for i := 0; i < 20; i++ { modified, err := mjs.Exec("main", map[string]interface{}{ "flush": func(args ...interface{}) { log.Println(args) }, }) t.Log(err, err == nil, modified) } }