package rest

import (
	"errors"
	"fmt"
	"git.nspix.com/golang/micro/gateway/http"
	"gorm.io/gorm"
	"strings"
	"testing"
)

type vm struct {
	Id int
}

func (v *vm) ModuleName() string {
	return "test"
}

func (v *vm) TableName() string {
	return "test"
}

func (v *vm) Scenario() []string {
	return nil
}

func (v *vm) OnBeforeCreateRequest(ctx *http.Context, tx *gorm.DB, model interface{}) (err error) {
	fmt.Println(v.Id)
	return errors.New("XXXXXXXX")
}

func TestEntity(t *testing.T) {
	vs := strings.SplitN("suffix:秒", ":", 2)
	fmt.Println(vs)
	fmt.Println(len(vs))
	return
	e := newEntity(&vm{}, &Options{
		Prefix:     "",
		Formatter:  DefaultFormatter,
		Middleware: nil,
	})
	mv := &vm{Id: 10}
	t.Log(e.callMethod(mv, "OnBeforeCreateRequestx", &http.Context{}, &gorm.DB{}, mv))
}
