-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin_test.go
61 lines (52 loc) · 2.1 KB
/
plugin_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
package test
import (
"fmt"
"runtime"
"strings"
)
func (s *CLITestSuite) TestPlugin() {
tests := []CLITest{
{args: "plugin1 arg1", fixture: "plugin/plugin1.golden"},
{args: "print args arg1 arg2 --meaningless-flag true arg3", fixture: "plugin/print-args.golden"},
{args: "version", fixture: "plugin/exact-name-overlap.golden", regex: true},
{args: "kafka something kafkaesque", fixture: "plugin/partial-name-overlap.golden"},
{args: "foo bar baz boo far foo bar baz --flag true", fixture: "plugin/long-plugin-name.golden"},
{args: "can print to stderr --meaningless-flag false and stdout", fixture: "plugin/print-stderr.golden"},
{args: "dash_test", fixture: "plugin/dash-test1.golden"},
{args: "dash-test", fixture: "plugin/dash-test1.golden"},
{args: "another_dash-test but-with two-args with dashes and-others_without them", fixture: "plugin/dash-test2.golden"},
{args: "cli command", fixture: "plugin/cli-commands.golden", regex: true},
{args: "plugin list", fixture: "plugin/list.golden"},
}
resetConfiguration(s.T(), true) // enable plugins
path := "test/bin:test/fixtures/input/plugin:test/fixtures/input/plugin/test"
if runtime.GOOS == "windows" {
path = strings.ReplaceAll(path, ":", ";")
}
if runtime.GOOS != "windows" {
for _, test := range tests {
test.workflow = true
test.env = []string{fmt.Sprintf("PATH=%s", path)}
s.runIntegrationTest(test)
}
}
}
func (s *CLITestSuite) TestPlugin_Disabled() {
tests := []CLITest{
{args: "plugin1 arg1", fixture: "plugin/plugin1-disabled.golden", exitCode: 1},
{args: "print args arg1 arg2 --meaningless-flag true arg3", fixture: "plugin/print-args-disabled.golden", exitCode: 1},
{args: "plugin list", fixture: "plugin/list-disabled.golden", exitCode: 1},
}
resetConfiguration(s.T(), false) // disable plugins
path := "test/fixtures/input/plugin:test/fixtures/input/plugin/test"
if runtime.GOOS == "windows" {
path = strings.ReplaceAll(path, ":", ";")
}
if runtime.GOOS != "windows" {
for _, test := range tests {
test.workflow = true
test.env = []string{fmt.Sprintf("PATH=%s", path)}
s.runIntegrationTest(test)
}
}
}