-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommando_test.go
More file actions
36 lines (30 loc) · 777 Bytes
/
commando_test.go
File metadata and controls
36 lines (30 loc) · 777 Bytes
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
package commando_test
import (
"fmt"
"testing"
"github.com/devproje/commando"
)
func TestSimple(t *testing.T) {
command := commando.NewCommando([]string{"test"})
command.Root("test", "test command", func(n *commando.Node) error {
fmt.Println("Hello, World!")
return nil
})
err := command.Execute()
if err != nil {
t.Errorf("simple command task failed: %v", err)
}
}
func TestComplex(t *testing.T) {
command := commando.NewCommando([]string{"test", "apply"})
command.ComplexRoot("test", "test command", []commando.Node{
command.Then("apply", "test command", func(n *commando.Node) error {
fmt.Println("apply task successful!")
return nil
}),
})
err := command.Execute()
if err != nil {
t.Errorf("complex command task failed: %v", err)
}
}