@@ -19,6 +19,7 @@ func TestExtraManifests_Load(t *testing.T) {
1919 files []string
2020 yamlFetchError error
2121 ymlFetchError error
22+ jsonFetchError error
2223
2324 expectedFound bool
2425 expectedFiles []string
@@ -46,16 +47,25 @@ func TestExtraManifests_Load(t *testing.T) {
4647 expectedFiles : []string {"/extra-manifests/another-test.yml" },
4748 },
4849 {
49- name : "both" ,
50+ name : "only-json" ,
51+ files : []string {"/extra-manifests/test.json" },
52+
53+ expectedFound : true ,
54+ expectedFiles : []string {"/extra-manifests/test.json" },
55+ },
56+ {
57+ name : "all" ,
5058 files : []string {
5159 "/extra-manifests/test.yaml" ,
5260 "/extra-manifests/another-test.yml" ,
61+ "/extra-manifests/test.json" ,
5362 },
5463
5564 expectedFound : true ,
5665 expectedFiles : []string {
5766 "/extra-manifests/test.yaml" ,
5867 "/extra-manifests/another-test.yml" ,
68+ "/extra-manifests/test.json" ,
5969 },
6070 },
6171 {
@@ -70,12 +80,19 @@ func TestExtraManifests_Load(t *testing.T) {
7080
7181 expectedError : "failed to load *.yml files: file does not exist" ,
7282 },
83+ {
84+ name : "error" ,
85+ jsonFetchError : os .ErrNotExist ,
86+
87+ expectedError : "failed to load *.json files: file does not exist" ,
88+ },
7389 }
7490
7591 for _ , tc := range cases {
7692 t .Run (tc .name , func (t * testing.T ) {
7793 yamlFiles := []* asset.File {}
7894 ymlFiles := []* asset.File {}
95+ jsonFiles := []* asset.File {}
7996 for _ , f := range tc .files {
8097 assetFile := & asset.File {
8198 Filename : f ,
@@ -87,6 +104,8 @@ func TestExtraManifests_Load(t *testing.T) {
87104 yamlFiles = append (yamlFiles , assetFile )
88105 case ".yml" :
89106 ymlFiles = append (ymlFiles , assetFile )
107+ case ".json" :
108+ jsonFiles = append (jsonFiles , assetFile )
90109 default :
91110 t .Error ("invalid extension" )
92111 }
@@ -101,7 +120,7 @@ func TestExtraManifests_Load(t *testing.T) {
101120 []* asset.File {},
102121 tc .yamlFetchError ,
103122 )
104- } else {
123+ } else if tc . ymlFetchError != nil {
105124 fileFetcher .EXPECT ().FetchByPattern ("extra-manifests/*.yaml" ).Return (yamlFiles , nil )
106125
107126 if tc .ymlFetchError != nil {
@@ -112,6 +131,18 @@ func TestExtraManifests_Load(t *testing.T) {
112131 } else {
113132 fileFetcher .EXPECT ().FetchByPattern ("extra-manifests/*.yml" ).Return (ymlFiles , nil )
114133 }
134+ } else {
135+ fileFetcher .EXPECT ().FetchByPattern ("extra-manifests/*.yaml" ).Return (yamlFiles , nil )
136+ fileFetcher .EXPECT ().FetchByPattern ("extra-manifests/*.yml" ).Return (ymlFiles , nil )
137+
138+ if tc .jsonFetchError != nil {
139+ fileFetcher .EXPECT ().FetchByPattern ("extra-manifests/*.json" ).Return (
140+ []* asset.File {},
141+ tc .jsonFetchError ,
142+ )
143+ } else {
144+ fileFetcher .EXPECT ().FetchByPattern ("extra-manifests/*.json" ).Return (jsonFiles , nil )
145+ }
115146 }
116147
117148 extraManifestsAsset := & ExtraManifests {}
0 commit comments