mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-01 02:01:21 +02:00
* Bump sprig to v3.1.0 test for mergeOverwrite * Let mergo not (accidentally) try to merge unexported fields This is also a good chance separate `HelmState` with the config loaded from YAML, which I had been wanting to do for a long time. Co-authored-by: Johannes Alkjær <johannes.alkjaer@wunderman.com> Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
54 lines
1.7 KiB
Go
54 lines
1.7 KiB
Go
package argparser
|
|
|
|
import (
|
|
"github.com/roboll/helmfile/pkg/state"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestGetArgs(t *testing.T) {
|
|
args := "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false --tiller-namespace ns"
|
|
defaultArgs := []string{"--recreate-pods", "--force"}
|
|
Helmdefaults := state.HelmSpec{KubeContext: "test", TillerNamespace: "test-namespace", Args: defaultArgs}
|
|
testState := &state.HelmState{
|
|
ReleaseSetSpec: state.ReleaseSetSpec{
|
|
HelmDefaults: Helmdefaults,
|
|
},
|
|
}
|
|
receivedArgs := GetArgs(args, testState)
|
|
|
|
expectedOutput := "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false --tiller-namespace ns --recreate-pods --force"
|
|
|
|
if compareArgs(expectedOutput, receivedArgs) == false {
|
|
t.Errorf("expected %s, got %s", expectedOutput, strings.Join(receivedArgs, " "))
|
|
}
|
|
}
|
|
|
|
func Test2(t *testing.T) {
|
|
args := "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false,app3.bootstrap=true --tiller-namespace ns"
|
|
defaultArgs := []string{"--recreate-pods", "--force"}
|
|
Helmdefaults := state.HelmSpec{KubeContext: "test", TillerNamespace: "test-namespace", Args: defaultArgs}
|
|
testState := &state.HelmState{
|
|
ReleaseSetSpec: state.ReleaseSetSpec{
|
|
HelmDefaults: Helmdefaults,
|
|
},
|
|
}
|
|
receivedArgs := GetArgs(args, testState)
|
|
|
|
expectedOutput := "--timeout=3600 --set app1.bootstrap=true --set app2.bootstrap=false,app3.bootstrap=true --tiller-namespace ns --recreate-pods --force"
|
|
|
|
if compareArgs(expectedOutput, receivedArgs) == false {
|
|
t.Errorf("expected %s, got %s", expectedOutput, strings.Join(receivedArgs, " "))
|
|
}
|
|
|
|
}
|
|
|
|
func compareArgs(expectedArgs string, args []string) bool {
|
|
|
|
if strings.Compare(strings.Join(args, " "), expectedArgs) != 0 {
|
|
return false
|
|
}
|
|
return true
|
|
|
|
}
|