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
3 years ago
|
package invoker
|
||
4 years ago
|
|
||
|
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)
|
||
3 years ago
|
Register("test", TestScript(0))
|
||
4 years ago
|
|
||
|
// 不存在
|
||
|
{
|
||
|
asserts.Error(RunDBScript("else", context.Background()))
|
||
|
}
|
||
|
|
||
|
// 存在
|
||
|
{
|
||
|
asserts.NoError(RunDBScript("test", context.Background()))
|
||
|
}
|
||
|
}
|
||
3 years ago
|
|
||
|
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)
|
||
|
}
|