-
Notifications
You must be signed in to change notification settings - Fork 1
/
command_test.go
40 lines (34 loc) · 890 Bytes
/
command_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package goofy_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/urionz/goofy"
"github.com/urionz/goofy/command"
"github.com/urionz/goofy/contracts"
)
type StructCommand struct {
}
func (*StructCommand) Handle(_ contracts.Application) *command.Command {
return &command.Command{
Name: "test",
Func: func(cmd *command.Command, args []string) error {
return nil
},
}
}
func TestApplication_AddCommander(t *testing.T) {
t.Run("add commander", func(t *testing.T) {
app := goofy.New()
err := app.AddCommanders(contracts.FuncCommander(func(app contracts.Application) *command.Command {
return &command.Command{
Name: "test",
Func: func(cmd *command.Command, args []string) error {
return nil
},
}
})).Error()
require.NoError(t, err)
err = app.AddCommanders(new(StructCommand)).Error()
require.NoError(t, err)
})
}