mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 05:02:35 +08:00
Plugins: Fail plugins installation on wrong args provided (#71355)
* Return error on plugin install extra args * Remove unused valid argument * Add log for wrong installation args
This commit is contained in:

committed by
GitHub

parent
82a5770376
commit
fe4a932c6e
26
pkg/cmd/grafana-cli/commands/install_command_test.go
Normal file
26
pkg/cmd/grafana-cli/commands/install_command_test.go
Normal file
@ -0,0 +1,26 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/cmd/grafana-cli/utils"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestValidateInput(t *testing.T) {
|
||||
t.Run("should print message for ignored args", func(t *testing.T) {
|
||||
mockCmdLine := &utils.MockCommandLine{}
|
||||
defer mockCmdLine.AssertExpectations(t)
|
||||
|
||||
cmdArgs := []string{"foo", "bar", "--bar=foo"}
|
||||
|
||||
mockArgs := &utils.MockArgs{}
|
||||
defer mockArgs.AssertExpectations(t)
|
||||
|
||||
mockArgs.On("Len").Return(len(cmdArgs))
|
||||
mockCmdLine.On("Args").Return(mockArgs).Times(1)
|
||||
|
||||
err := validateInput(mockCmdLine)
|
||||
require.EqualError(t, err, "install only supports 2 arguments: plugin and version")
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user