@@ -188,6 +188,50 @@ ${{ step.stderr}}
188188 }
189189}
190190
191+ func TestRenderStepMap (t * testing.T ) {
192+ stepCtx := & StepContext {
193+ PreviousStep : StepResult {
194+ files : & StepChanges {
195+ Modified : []string {"go.mod" },
196+ Added : []string {"main.go.swp" },
197+ Deleted : []string {".DS_Store" },
198+ Renamed : []string {"new-filename.txt" },
199+ },
200+ Stdout : bytes .NewBufferString ("this is previous step's stdout" ),
201+ Stderr : bytes .NewBufferString ("this is previous step's stderr" ),
202+ },
203+ Outputs : map [string ]interface {}{},
204+ Repository : graphql.Repository {
205+ Name : "github.com/sourcegraph/src-cli" ,
206+ FileMatches : map [string ]bool {
207+ "README.md" : true ,
208+ "main.go" : true ,
209+ },
210+ },
211+ }
212+
213+ input := map [string ]string {
214+ "/tmp/my-file.txt" : `${{ previous_step.modified_files }}` ,
215+ "/tmp/my-other-file.txt" : `${{ previous_step.added_files }}` ,
216+ "/tmp/my-other-file2.txt" : `${{ previous_step.deleted_files }}` ,
217+ }
218+
219+ have , err := renderStepMap (input , stepCtx )
220+ if err != nil {
221+ t .Fatalf ("unexpected error: %s" , err )
222+ }
223+
224+ want := map [string ]string {
225+ "/tmp/my-file.txt" : "[go.mod]" ,
226+ "/tmp/my-other-file.txt" : "[main.go.swp]" ,
227+ "/tmp/my-other-file2.txt" : "[.DS_Store]" ,
228+ }
229+
230+ if diff := cmp .Diff (want , have ); diff != "" {
231+ t .Fatalf ("wrong output:\n %s" , diff )
232+ }
233+ }
234+
191235func TestRenderChangesetTemplateField (t * testing.T ) {
192236 // To avoid bugs due to differences between test setup and actual code, we
193237 // do the actual parsing of YAML here to get an interface{} which we'll put
0 commit comments