mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-21 11:20:23 +02:00
* fix #1095 Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
@@ -1,61 +1,11 @@
|
||||
package argparser
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/state"
|
||||
)
|
||||
|
||||
// TestGetArgs tests the GetArgs function
|
||||
func TestGetArgs(t *testing.T) {
|
||||
tests := []struct {
|
||||
args string
|
||||
expected string
|
||||
defaultArgs []string
|
||||
defaultDiffArgs []string
|
||||
opts *GetArgsOptions
|
||||
}{
|
||||
{
|
||||
args: "-f a.yaml -f b.yaml -i --set app1.bootstrap=true --set app2.bootstrap=false",
|
||||
defaultArgs: []string{"--recreate-pods", "--force"},
|
||||
defaultDiffArgs: []string{"--suppress", "Deployment"},
|
||||
opts: &GetArgsOptions{WithDiffArgs: true},
|
||||
expected: "-f a.yaml -f b.yaml -i --set app1.bootstrap=true --set app2.bootstrap=false --recreate-pods --force --suppress Deployment",
|
||||
},
|
||||
{
|
||||
args: "-e a.yaml -d b.yaml -i --set app1.bootstrap=true --set app2.bootstrap=false",
|
||||
defaultArgs: []string{"-q www", "-w"},
|
||||
defaultDiffArgs: []string{},
|
||||
expected: "-e a.yaml -d b.yaml -i --set app1.bootstrap=true --set app2.bootstrap=false -q www -w",
|
||||
},
|
||||
{
|
||||
args: "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false",
|
||||
expected: "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false",
|
||||
},
|
||||
{
|
||||
args: "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false,app3.bootstrap=true",
|
||||
defaultArgs: []string{"--recreate-pods", "--force"},
|
||||
defaultDiffArgs: []string{"--suppress", "Deployment"},
|
||||
opts: &GetArgsOptions{},
|
||||
expected: "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false,app3.bootstrap=true --recreate-pods --force",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
Helmdefaults := state.HelmSpec{KubeContext: "test", Args: test.defaultArgs, DiffArgs: test.defaultDiffArgs}
|
||||
testState := &state.HelmState{
|
||||
ReleaseSetSpec: state.ReleaseSetSpec{
|
||||
HelmDefaults: Helmdefaults,
|
||||
},
|
||||
}
|
||||
receivedArgs := GetArgs(test.args, testState, test.opts)
|
||||
|
||||
require.Equalf(t, test.expected, strings.Join(receivedArgs, " "), "expected args %s, received args %s", test.expected, strings.Join(receivedArgs, " "))
|
||||
}
|
||||
}
|
||||
|
||||
// TestIsNewFlag tests the isNewFlag function
|
||||
func TestIsNewFlag(t *testing.T) {
|
||||
tests := []struct {
|
||||
|
||||
Reference in New Issue
Block a user