You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
658 B
40 lines
658 B
package invoker
|
|
|
|
import (
|
|
"context"
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
)
|
|
|
|
type TestScript int
|
|
|
|
func (script TestScript) Run(ctx context.Context) {
|
|
|
|
}
|
|
|
|
func TestRunDBScript(t *testing.T) {
|
|
asserts := assert.New(t)
|
|
Register("test", TestScript(0))
|
|
|
|
// 不存在
|
|
{
|
|
asserts.Error(RunDBScript("else", context.Background()))
|
|
}
|
|
|
|
// 存在
|
|
{
|
|
asserts.NoError(RunDBScript("test", context.Background()))
|
|
}
|
|
}
|
|
|
|
func TestListPrefix(t *testing.T) {
|
|
asserts := assert.New(t)
|
|
Register("U1", TestScript(0))
|
|
Register("U2", TestScript(0))
|
|
Register("U3", TestScript(0))
|
|
Register("P1", TestScript(0))
|
|
|
|
res := ListPrefix("U")
|
|
asserts.Len(res, 3)
|
|
}
|