@@ -14,21 +14,10 @@ import (
1414 "github.com/go-test/deep"
1515)
1616
17- // type mockConfigManageriface interface {
18- // Retrieve(tokens []string, config generator.GenVarsConfig) (generator.ParsedMap, error)
19- // RetrieveWithInputReplaced(input string, config generator.GenVarsConfig) (string, error)
20- // Insert(force bool) error
21- // }
22-
2317type mockGenerator struct {
2418 generate func (tokens []string ) (generator.ParsedMap , error )
2519}
2620
27- // var (
28- // testKey = "FOO#/test"
29- // testVal = "val1"
30- // )
31-
3221func (m * mockGenerator ) Generate (tokens []string ) (generator.ParsedMap , error ) {
3322 if m .generate != nil {
3423 return m .generate (tokens )
@@ -40,14 +29,10 @@ func (m *mockGenerator) Generate(tokens []string) (generator.ParsedMap, error) {
4029 return pm , nil
4130}
4231
43- type mockGenIface interface {
44- Generate (tokens []string ) (generator.ParsedMap , error )
45- }
46-
4732func Test_Retrieve_from_token_list (t * testing.T ) {
4833 tests := map [string ]struct {
4934 tokens []string
50- genvar mockGenIface
35+ genvar * mockGenerator
5136 expectKey string
5237 expectVal string
5338 }{
@@ -81,7 +66,7 @@ func Test_retrieveWithInputReplaced(t *testing.T) {
8166 tests := map [string ]struct {
8267 name string
8368 input string
84- genvar mockGenIface
69+ genvar * mockGenerator
8570 expect string
8671 }{
8772 "strYaml" : {
@@ -184,44 +169,6 @@ foo23 = val1
184169 }
185170}
186171
187- // func Test_replaceString(t *testing.T) {
188- // tests := []struct {
189- // name string
190- // parsedMap generator.ParsedMap
191- // inputStr string
192- // expectStr string
193- // }{
194- // {
195- // name: "ordered correctly",
196- // parsedMap: generator.ParsedMap{
197- // "AZKVSECRET#/test-vault/db-config|user": "foo",
198- // "AZKVSECRET#/test-vault/db-config|pass": "bar",
199- // "AZKVSECRET#/test-vault/db-config": fmt.Sprintf("%v", "{\"user\": \"foo\", \"pass\": \"bar\"}"),
200- // },
201- // inputStr: `app: foo
202- // db2: AZKVSECRET#/test-vault/db-config
203- // db:
204- // user: AZKVSECRET#/test-vault/db-config|user
205- // pass: AZKVSECRET#/test-vault/db-config|pass
206- // `,
207- // expectStr: `app: foo
208- // db2: {"user": "foo", "pass": "bar"}
209- // db:
210- // user: foo
211- // pass: bar
212- // `,
213- // },
214- // }
215- // for _, tt := range tests {
216- // t.Run(tt.name, func(t *testing.T) {
217- // got := replaceString(tt.parsedMap, tt.inputStr)
218- // if got != tt.expectStr {
219- // t.Errorf(testutils.TestPhrase, got, tt.expectStr)
220- // }
221- // })
222- // }
223- // }
224-
225172type testSimpleStruct struct {
226173 Foo string `json:"foo" yaml:"foo"`
227174 Bar string `json:"bar" yaml:"bar"`
@@ -558,9 +505,6 @@ func Test_YamlRetrieveMarshalled_errored_in_marshal(t *testing.T) {
558505 c := configmanager .New (context .TODO ())
559506 c .Config .WithTokenSeparator ("://" )
560507 c .WithGenerator (m )
561- // input := &testNestedStruct{}
562- // var errYaml = func() {}
563- // type failingMarshaler struct{}
564508 err := c .RetrieveMarshalledYaml (& struct {
565509 A int
566510 B map [string ]int `yaml:",inline"`
@@ -644,116 +588,3 @@ func Test_Generator_Config_(t *testing.T) {
644588 })
645589 }
646590}
647-
648- // func Test_KubeControllerSpecHelper(t *testing.T) {
649- // tests := []struct {
650- // name string
651- // testType testSimpleStruct
652- // expect testSimpleStruct
653- // cfmgr func(t *testing.T) mockConfigManageriface
654- // }{
655- // {
656- // name: "happy path simple struct",
657- // testType: testSimpleStruct{
658- // Foo: testTokenAWS,
659- // Bar: "quz",
660- // },
661- // expect: testSimpleStruct{
662- // Foo: "baz",
663- // Bar: "quz",
664- // },
665- // cfmgr: func(t *testing.T) mockConfigManageriface {
666- // mcm := &MockCfgMgr{}
667- // mcm.retrieveInput = func(input string, config generator.GenVarsConfig) (string, error) {
668- // return `{"foo":"baz","bar":"quz"}`, nil
669- // }
670- // return mcm
671- // },
672- // },
673- // {
674- // name: "happy path simple struct2",
675- // testType: testSimpleStruct{
676- // Foo: "AWSSECRETS:///bar/foo2",
677- // Bar: "quz",
678- // },
679- // expect: testSimpleStruct{
680- // Foo: "baz2",
681- // Bar: "quz",
682- // },
683- // cfmgr: func(t *testing.T) mockConfigManageriface {
684- // mcm := &MockCfgMgr{}
685- // mcm.retrieveInput = func(input string, config generator.GenVarsConfig) (string, error) {
686- // return `{"foo":"baz2","bar":"quz"}`, nil
687- // }
688- // return mcm
689- // },
690- // },
691- // }
692- // for _, tt := range tests {
693- // t.Run(tt.name, func(t *testing.T) {
694-
695- // config := generator.NewConfig()
696- // resp, err := KubeControllerSpecHelper(tt.testType, tt.cfmgr(t), *config)
697- // if err != nil {
698- // t.Errorf(testutils.TestPhrase, err.Error(), nil)
699- // }
700- // if !reflect.DeepEqual(resp, &tt.expect) {
701- // t.Error("")
702- // }
703- // })
704- // }
705- // }
706-
707- // func Test_KubeControllerComplex(t *testing.T) {
708- // tests := []struct {
709- // name string
710- // testType testNestedStruct
711- // expect testNestedStruct
712- // cfmgr func(t *testing.T) mockConfigManageriface
713- // }{
714- // {
715- // name: "happy path complex struct",
716- // testType: testNestedStruct{
717- // Foo: testTokenAWS,
718- // Bar: "quz",
719- // Lol: testLol{
720- // Bla: "booo",
721- // Another: testAnotherNEst{
722- // Number: 1235,
723- // Float: 123.09,
724- // },
725- // },
726- // },
727- // expect: testNestedStruct{
728- // Foo: "baz",
729- // Bar: "quz",
730- // Lol: testLol{
731- // Bla: "booo",
732- // Another: testAnotherNEst{
733- // Number: 1235,
734- // Float: 123.09,
735- // },
736- // },
737- // },
738- // cfmgr: func(t *testing.T) mockConfigManageriface {
739- // mcm := &MockCfgMgr{}
740- // mcm.retrieveInput = func(input string, config generator.GenVarsConfig) (string, error) {
741- // return `{"foo":"baz","bar":"quz", "lol":{"bla":"booo","another":{"number": 1235, "float": 123.09}}}`, nil
742- // }
743- // return mcm
744- // },
745- // },
746- // }
747- // for _, tt := range tests {
748- // t.Run(tt.name, func(t *testing.T) {
749- // config := generator.NewConfig().WithTokenSeparator("://")
750- // got, err := KubeControllerSpecHelper(tt.testType, tt.cfmgr(t), *config)
751- // if err != nil {
752- // t.Errorf(testutils.TestPhrase, err.Error(), nil)
753- // }
754- // if !reflect.DeepEqual(got, &tt.expect) {
755- // t.Errorf(testutils.TestPhraseWithContext, "returned types do not deep equal", got, tt.expect)
756- // }
757- // })
758- // }
759- // }
0 commit comments