Files
grafana/pkg/cmd/grafana-cli/commands/install_command_test.go
Hugo Kiyodi Oshiro fe4a932c6e 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
2023-07-12 13:52:12 +02:00

27 lines
674 B
Go

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")
})
}