33 lines
517 B
Go
33 lines
517 B
Go
|
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"))
|
||
|
}
|
||
|
}
|
||
|
}
|