1- package helminstaller_test
1+ package helminstaller
22
33import (
44 "os"
@@ -8,53 +8,52 @@ import (
88 . "github.com/onsi/gomega"
99
1010 "github.com/devstream-io/devstream/internal/pkg/configmanager"
11- "github.com/devstream-io/devstream/internal/pkg/plugin/helminstaller"
1211 "github.com/devstream-io/devstream/internal/pkg/plugin/helminstaller/defaults"
1312 "github.com/devstream-io/devstream/internal/pkg/plugin/installer"
1413 "github.com/devstream-io/devstream/internal/pkg/plugin/installer/helm"
1514 "github.com/devstream-io/devstream/internal/pkg/statemanager"
1615)
1716
1817var _ = Describe ("helm installer test" , func () {
19- Context ("GetDefaultOptionsByInstanceID " , func () {
18+ Context ("getDefaultOptionsByInstanceID " , func () {
2019 defaults .DefaultOptionsMap ["foo" ] = & helm.Options {
2120 ValuesYaml : "foo: bar" ,
2221 }
2322
2423 It ("should exists" , func () {
25- opts := helminstaller . GetDefaultOptionsByInstanceID ("foo-001" )
24+ opts := getDefaultOptionsByInstanceID ("foo-001" )
2625 Expect (opts ).NotTo (BeNil ())
2726 Expect (opts .ValuesYaml ).To (Equal ("foo: bar" ))
2827 })
2928
3029 It ("should not exists" , func () {
31- optsNil := helminstaller . GetDefaultOptionsByInstanceID ("fo-001" )
30+ optsNil := getDefaultOptionsByInstanceID ("fo-001" )
3231 Expect (optsNil ).To (BeNil ())
3332 })
3433 })
3534
36- Context ("GetStatusGetterFuncByInstanceID " , func () {
35+ Context ("getStatusGetterFuncByInstanceID " , func () {
3736 defaults .StatusGetterFuncMap = map [string ]installer.StatusGetterOperation {
3837 "foo" : func (options configmanager.RawOptions ) (statemanager.ResourceStatus , error ) {
3938 return nil , nil
4039 },
4140 }
4241
4342 It ("should exists" , func () {
44- fn := helminstaller . GetStatusGetterFuncByInstanceID ("foo-001" )
43+ fn := getStatusGetterFuncByInstanceID ("foo-001" )
4544 Expect (fn ).NotTo (BeNil ())
4645 })
4746
4847 It ("should not exists" , func () {
49- fn := helminstaller . GetStatusGetterFuncByInstanceID ("fooo" )
48+ fn := getStatusGetterFuncByInstanceID ("fooo" )
5049 Expect (fn ).To (BeNil ())
5150 })
5251 })
5352
54- Context ("RenderDefaultConfig " , func () {
53+ Context ("renderDefaultConfig " , func () {
5554 opts := configmanager.RawOptions {}
5655 opts ["instanceID" ] = interface {}("argocd-001" )
57- newOpts , err := helminstaller . RenderDefaultConfig (opts )
56+ newOpts , err := renderDefaultConfig (opts )
5857 Expect (err ).To (BeNil ())
5958
6059 helmOpts , err := helm .NewOptions (newOpts )
@@ -64,11 +63,11 @@ var _ = Describe("helm installer test", func() {
6463 Expect (helmOpts .Repo .URL ).To (Equal (defaults .DefaultConfigWithArgoCD .Repo .URL ))
6564 })
6665
67- Context ("RenderValuesYaml " , func () {
66+ Context ("renderValuesYaml " , func () {
6867 It ("config with yaml" , func () {
6968 opts := configmanager.RawOptions {}
7069 opts ["valuesYaml" ] = interface {}("foo: bar" )
71- newOpts , err := helminstaller . RenderValuesYaml (opts )
70+ newOpts , err := renderValuesYaml (opts )
7271 Expect (err ).To (BeNil ())
7372
7473 helmOpts , err := helm .NewOptions (newOpts )
@@ -83,7 +82,7 @@ var _ = Describe("helm installer test", func() {
8382
8483 opts := configmanager.RawOptions {}
8584 opts ["valuesYaml" ] = interface {}("./values.yaml" )
86- newOpts , err := helminstaller . RenderValuesYaml (opts )
85+ newOpts , err := renderValuesYaml (opts )
8786 Expect (err ).To (BeNil ())
8887
8988 helmOpts , err := helm .NewOptions (newOpts )
@@ -96,14 +95,29 @@ var _ = Describe("helm installer test", func() {
9695 })
9796 })
9897
99- Context ("IndexStatusGetterFunc " , func () {
98+ Context ("indexStatusGetterFunc " , func () {
10099 opts1 := configmanager.RawOptions {
101100 "instanceID" : interface {}("argocd-001" ),
102101 }
103102
104103 defaults .StatusGetterFuncMap ["argocd" ] = defaults .GetArgoCDStatus
105104
106- fn1 := helminstaller . IndexStatusGetterFunc (opts1 )
105+ fn1 := indexStatusGetterFunc (opts1 )
107106 Expect (reflect .ValueOf (fn1 ).Pointer ()).To (Equal (reflect .ValueOf (defaults .GetArgoCDStatus ).Pointer ()))
108107 })
108+
109+ Context ("getLongestMatchedName" , func () {
110+ testList := []string {"abc" , "abcd" , "ab" }
111+ retStr := getLongestMatchedName (testList )
112+ Expect (retStr ).To (Equal ("abcd" ))
113+ })
114+
115+ Context ("getDefaultOptionsByInstanceID" , func () {
116+ opt1 := getDefaultOptionsByInstanceID ("argocd" )
117+ opt2 := getDefaultOptionsByInstanceID ("argocd-001" )
118+ opt3 := getDefaultOptionsByInstanceID ("argocd001" )
119+
120+ Expect (opt1 ).To (Equal (opt2 ))
121+ Expect (opt2 ).To (Equal (opt3 ))
122+ })
109123})
0 commit comments