-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCommand_test.go
63 lines (50 loc) · 1.2 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package unison
import (
"testing"
"gopkg.in/bwmarrin/Discordgo.v0"
)
func testCommandAction(ctx *Context, msg *discordgo.Message, request string) error {
return nil
}
func TestCommandParser(t *testing.T) {
var cmd = &Command{
Name: "test",
Usage: "unit testing kek",
Action: testCommandAction,
Flags: &struct {
Input string
Output []string
}{},
}
cmd.buildCommand()
userInput := "test lol kek \"testing test lol2\" --input=\"test\""
cmd.parseInput(userInput)
}
func TestCommandParserWithContentCheck(t *testing.T) {
var args struct {
Input string
Output []string
}
var cmd = &Command{
Name: "test",
Usage: "unit testing kek",
Action: testCommandAction,
Flags: &args,
}
cmd.buildCommand()
userInput := "test lol kek \"testing test lol2\" --input=\"test\""
cmd.parseInput(userInput)
if args.Input != "test" {
t.Errorf("Incorrectly parsed user input. Expected `test`, got %s\n", args.Input)
}
}
func TestCommandParserWithoutFlags(t *testing.T) {
var cmd = &Command{
Name: "test",
Usage: "unit testing kek",
Action: testCommandAction,
}
cmd.buildCommand()
userInput := "test lol kek \"testing test lol2\" --input=\"test\""
cmd.parseInput(userInput)
}