client/tests/plugin_run.go

32 lines
647 B
Go
Raw Permalink Normal View History

2024-06-07 15:33:03 +08:00
package main
import (
"apigo.cloud/git/apigo/gojs"
"current-plugin"
"fmt"
"github.com/ssgo/u"
"os"
"strings"
)
func main() {
testOK := false
client.Bind("setTestOK", func(testIsOK bool) {
testOK = testIsOK
})
if files, err := os.ReadDir("."); err == nil {
for _, f := range files {
if !f.IsDir() && strings.HasSuffix(f.Name(), "_test.js") {
testName := f.Name()[0 : len(f.Name())-8]
r, err := gojs.RunFile(f.Name(), nil)
if err != nil || r != true || !testOK {
fmt.Println(u.BRed("test "+testName+" failed"), r, err)
} else {
fmt.Println(u.Green("test "+testName), u.BGreen("OK"))
}
}
}
}
}