mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-25 15:39:37 -05:00
bd63aa3c6b
sed -i '1i/*\nCopyright (c) Edgeless Systems GmbH\n\nSPDX-License-Identifier: AGPL-3.0-only\n*/\n' `grep -rL --include='*.go' 'DO NOT EDIT'` gofumpt -w .
45 lines
824 B
Go
45 lines
824 B
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestIsCloudProvider(t *testing.T) {
|
|
testCases := map[string]struct {
|
|
pos int
|
|
args []string
|
|
wantErr bool
|
|
}{
|
|
"gcp": {0, []string{"gcp"}, false},
|
|
"azure": {1, []string{"foo", "azure"}, false},
|
|
"foo": {0, []string{"foo"}, true},
|
|
"empty": {0, []string{""}, true},
|
|
"unknown": {0, []string{"unknown"}, true},
|
|
}
|
|
|
|
for name, tc := range testCases {
|
|
t.Run(name, func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
testCmd := &cobra.Command{Args: isCloudProvider(tc.pos)}
|
|
|
|
err := testCmd.ValidateArgs(tc.args)
|
|
|
|
if tc.wantErr {
|
|
assert.Error(err)
|
|
} else {
|
|
assert.NoError(err)
|
|
}
|
|
})
|
|
}
|
|
}
|