@@ -14,21 +14,10 @@ import (
14
14
"github.com/go-test/deep"
15
15
)
16
16
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
-
23
17
type mockGenerator struct {
24
18
generate func (tokens []string ) (generator.ParsedMap , error )
25
19
}
26
20
27
- // var (
28
- // testKey = "FOO#/test"
29
- // testVal = "val1"
30
- // )
31
-
32
21
func (m * mockGenerator ) Generate (tokens []string ) (generator.ParsedMap , error ) {
33
22
if m .generate != nil {
34
23
return m .generate (tokens )
@@ -40,14 +29,10 @@ func (m *mockGenerator) Generate(tokens []string) (generator.ParsedMap, error) {
40
29
return pm , nil
41
30
}
42
31
43
- type mockGenIface interface {
44
- Generate (tokens []string ) (generator.ParsedMap , error )
45
- }
46
-
47
32
func Test_Retrieve_from_token_list (t * testing.T ) {
48
33
tests := map [string ]struct {
49
34
tokens []string
50
- genvar mockGenIface
35
+ genvar * mockGenerator
51
36
expectKey string
52
37
expectVal string
53
38
}{
@@ -81,7 +66,7 @@ func Test_retrieveWithInputReplaced(t *testing.T) {
81
66
tests := map [string ]struct {
82
67
name string
83
68
input string
84
- genvar mockGenIface
69
+ genvar * mockGenerator
85
70
expect string
86
71
}{
87
72
"strYaml" : {
@@ -184,44 +169,6 @@ foo23 = val1
184
169
}
185
170
}
186
171
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
-
225
172
type testSimpleStruct struct {
226
173
Foo string `json:"foo" yaml:"foo"`
227
174
Bar string `json:"bar" yaml:"bar"`
@@ -558,9 +505,6 @@ func Test_YamlRetrieveMarshalled_errored_in_marshal(t *testing.T) {
558
505
c := configmanager .New (context .TODO ())
559
506
c .Config .WithTokenSeparator ("://" )
560
507
c .WithGenerator (m )
561
- // input := &testNestedStruct{}
562
- // var errYaml = func() {}
563
- // type failingMarshaler struct{}
564
508
err := c .RetrieveMarshalledYaml (& struct {
565
509
A int
566
510
B map [string ]int `yaml:",inline"`
@@ -644,116 +588,3 @@ func Test_Generator_Config_(t *testing.T) {
644
588
})
645
589
}
646
590
}
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