db/db_test.go

33 lines
517 B
Go
Raw Permalink Normal View History

2024-10-11 11:32:50 +08:00
package db_test
import (
"fmt"
"os"
"testing"
"apigo.cc/gojs"
_ "apigo.cc/gojs/db"
"github.com/ssgo/u"
_ "modernc.org/sqlite"
)
func Test(t *testing.T) {
// gojs.ExportForDev()
defer os.Remove("test.db")
r, err := gojs.RunFile("db_test.js", "Tom")
if err != nil {
t.Fatal(err)
} else {
user := struct {
Id int
Name string
}{}
u.Convert(r, &user)
if user.Id != 1 || user.Name != "Tom" {
t.Fatal("user info is error", r)
} else {
fmt.Println(u.BGreen("test succeess"))
}
}
}