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:
Hugo Kiyodi Oshiro
2023-07-12 13:52:12 +02:00
committed by GitHub
parent 82a5770376
commit fe4a932c6e
4 changed files with 357 additions and 3 deletions

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