mirror of
https://github.com/grafana/grafana.git
synced 2025-09-25 12:13:55 +08:00
grafana-cli: Upgrade to urfave/cli v2 (#22402)
* grafana-cli: Upgrade to urfave/cli v2
This commit is contained in:
@ -14,76 +14,55 @@ func TestMissingPath(t *testing.T) {
|
||||
Convey("ls command", t, func() {
|
||||
validateLsCommand = org
|
||||
|
||||
Convey("Missing path", func() {
|
||||
commandLine := &commandstest.FakeCommandLine{
|
||||
CliArgs: []string{"ls"},
|
||||
GlobalFlags: &commandstest.FakeFlagger{
|
||||
Data: map[string]interface{}{
|
||||
"path": "",
|
||||
},
|
||||
},
|
||||
}
|
||||
Convey("Missing path flag", func() {
|
||||
cmd := Command{}
|
||||
c, err := commandstest.NewCliContext(map[string]string{})
|
||||
So(err, ShouldBeNil)
|
||||
s.IoHelper = &commandstest.FakeIoUtil{}
|
||||
|
||||
Convey("should return error", func() {
|
||||
err := lsCommand(commandLine)
|
||||
So(err, ShouldNotBeNil)
|
||||
err := cmd.lsCommand(c)
|
||||
So(err, ShouldBeError, "missing path flag")
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Path is not a directory", func() {
|
||||
commandLine := &commandstest.FakeCommandLine{
|
||||
CliArgs: []string{"ls"},
|
||||
GlobalFlags: &commandstest.FakeFlagger{
|
||||
Data: map[string]interface{}{
|
||||
"path": "/var/lib/grafana/plugins",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
c, err := commandstest.NewCliContext(map[string]string{"path": "/var/lib/grafana/plugins"})
|
||||
So(err, ShouldBeNil)
|
||||
s.IoHelper = &commandstest.FakeIoUtil{
|
||||
FakeIsDirectory: false,
|
||||
}
|
||||
cmd := Command{}
|
||||
|
||||
Convey("should return error", func() {
|
||||
err := lsCommand(commandLine)
|
||||
err := cmd.lsCommand(c)
|
||||
So(err, ShouldNotBeNil)
|
||||
})
|
||||
})
|
||||
|
||||
Convey("can override validateLsCommand", func() {
|
||||
commandLine := &commandstest.FakeCommandLine{
|
||||
CliArgs: []string{"ls"},
|
||||
GlobalFlags: &commandstest.FakeFlagger{
|
||||
Data: map[string]interface{}{
|
||||
"path": "/var/lib/grafana/plugins",
|
||||
},
|
||||
},
|
||||
}
|
||||
c, err := commandstest.NewCliContext(map[string]string{"path": "/var/lib/grafana/plugins"})
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
validateLsCommand = func(pluginDir string) error {
|
||||
return errors.New("dummie error")
|
||||
return errors.New("dummy error")
|
||||
}
|
||||
|
||||
Convey("should return error", func() {
|
||||
err := lsCommand(commandLine)
|
||||
So(err.Error(), ShouldEqual, "dummie error")
|
||||
cmd := Command{}
|
||||
err := cmd.lsCommand(c)
|
||||
So(err.Error(), ShouldEqual, "dummy error")
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Validate that validateLsCommand is reset", func() {
|
||||
commandLine := &commandstest.FakeCommandLine{
|
||||
CliArgs: []string{"ls"},
|
||||
GlobalFlags: &commandstest.FakeFlagger{
|
||||
Data: map[string]interface{}{
|
||||
"path": "/var/lib/grafana/plugins",
|
||||
},
|
||||
},
|
||||
}
|
||||
c, err := commandstest.NewCliContext(map[string]string{"path": "/var/lib/grafana/plugins"})
|
||||
So(err, ShouldBeNil)
|
||||
cmd := Command{}
|
||||
|
||||
Convey("should return error", func() {
|
||||
err := lsCommand(commandLine)
|
||||
So(err.Error(), ShouldNotEqual, "dummie error")
|
||||
err := cmd.lsCommand(c)
|
||||
So(err.Error(), ShouldNotEqual, "dummy error")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user