@@ -131,10 +131,17 @@ Run 'getenvoy extension examples add --help' for usage.
131
131
Done!
132
132
` ))
133
133
By ("verifying file system" )
134
- Expect (filepath .Join (tempDir , ".getenvoy/extension/examples/default/README.md" )).To (BeAnExistingFile ())
134
+ readmePath := filepath .Join (tempDir , ".getenvoy/extension/examples/default/README.md" )
135
+ Expect (readmePath ).To (BeAnExistingFile ())
135
136
Expect (filepath .Join (tempDir , ".getenvoy/extension/examples/default/envoy.tmpl.yaml" )).To (BeAnExistingFile ())
136
137
Expect (filepath .Join (tempDir , ".getenvoy/extension/examples/default/example.yaml" )).To (BeAnExistingFile ())
137
138
Expect (filepath .Join (tempDir , ".getenvoy/extension/examples/default/extension.json" )).To (BeAnExistingFile ())
139
+ // Check README substitution: ${EXTENSION_CONFIG_FILE_NAME} must be replaced with "extension.json".
140
+ data , err := ioutil .ReadFile (readmePath )
141
+ Expect (err ).ToNot (HaveOccurred ())
142
+ readme := string (data )
143
+ Expect (readme ).To (ContainSubstring ("extension.json" ))
144
+ Expect (readme ).NotTo (ContainSubstring ("EXTENSION_CONFIG_FILE_NAME" ))
138
145
})
139
146
140
147
It ("should create example setup with a given --name" , func () {
@@ -160,10 +167,17 @@ Done!
160
167
Done!
161
168
` ))
162
169
By ("verifying file system" )
163
- Expect (filepath .Join (tempDir , ".getenvoy/extension/examples/advanced/README.md" )).To (BeAnExistingFile ())
170
+ readmePath := filepath .Join (tempDir , ".getenvoy/extension/examples/advanced/README.md" )
171
+ Expect (readmePath ).To (BeAnExistingFile ())
164
172
Expect (filepath .Join (tempDir , ".getenvoy/extension/examples/advanced/envoy.tmpl.yaml" )).To (BeAnExistingFile ())
165
173
Expect (filepath .Join (tempDir , ".getenvoy/extension/examples/advanced/example.yaml" )).To (BeAnExistingFile ())
166
174
Expect (filepath .Join (tempDir , ".getenvoy/extension/examples/advanced/extension.json" )).To (BeAnExistingFile ())
175
+ // Check README substitution: ${EXTENSION_CONFIG_FILE_NAME} must be replaced with "extension.json".
176
+ data , err := ioutil .ReadFile (readmePath )
177
+ Expect (err ).ToNot (HaveOccurred ())
178
+ readme := string (data )
179
+ Expect (readme ).To (ContainSubstring ("extension.json" ))
180
+ Expect (readme ).NotTo (ContainSubstring ("${EXTENSION_CONFIG_FILE_NAME}" ))
167
181
})
168
182
169
183
It ("should fail if such example already exists" , func () {
@@ -186,6 +200,42 @@ Done!
186
200
Run 'getenvoy extension examples add --help' for usage.
187
201
` ))
188
202
})
203
+
204
+ It ("should create 'default' example setup when no --name is omitted for TinyGo" , func () {
205
+ By ("simulating a workspace without any examples" )
206
+ err := copy .Copy ("testdata/workspace4" , tempDir )
207
+ Expect (err ).NotTo (HaveOccurred ())
208
+
209
+ By ("changing to a workspace dir" )
210
+ chdir (tempDir )
211
+
212
+ By ("running command" )
213
+ c .SetArgs ([]string {"extension" , "examples" , "add" })
214
+ err = cmdutil .Execute (c )
215
+ Expect (err ).ToNot (HaveOccurred ())
216
+
217
+ By ("verifying command output" )
218
+ Expect (stdout .String ()).To (BeEmpty ())
219
+ Expect (stderr .String ()).To (Equal (`Scaffolding a new example setup:
220
+ * .getenvoy/extension/examples/default/README.md
221
+ * .getenvoy/extension/examples/default/envoy.tmpl.yaml
222
+ * .getenvoy/extension/examples/default/example.yaml
223
+ * .getenvoy/extension/examples/default/extension.txt
224
+ Done!
225
+ ` ))
226
+ By ("verifying file system" )
227
+ readmePath := filepath .Join (tempDir , ".getenvoy/extension/examples/default/README.md" )
228
+ Expect (readmePath ).To (BeAnExistingFile ())
229
+ Expect (filepath .Join (tempDir , ".getenvoy/extension/examples/default/envoy.tmpl.yaml" )).To (BeAnExistingFile ())
230
+ Expect (filepath .Join (tempDir , ".getenvoy/extension/examples/default/example.yaml" )).To (BeAnExistingFile ())
231
+ Expect (filepath .Join (tempDir , ".getenvoy/extension/examples/default/extension.txt" )).To (BeAnExistingFile ())
232
+ // Check README substitution: ${EXTENSION_CONFIG_FILE_NAME} must be replaced with "extension.txt".
233
+ data , err := ioutil .ReadFile (readmePath )
234
+ Expect (err ).ToNot (HaveOccurred ())
235
+ readme := string (data )
236
+ Expect (readme ).To (ContainSubstring ("extension.txt" ))
237
+ Expect (readme ).NotTo (ContainSubstring ("${EXTENSION_CONFIG_FILE_NAME}" ))
238
+ })
189
239
})
190
240
191
241
Context ("outside of a workspace directory" , func () {
0 commit comments