@@ -198,6 +198,40 @@ func TestExtractAPMDependenciesGitHubApp(t *testing.T) {
198198 })
199199}
200200
201+ func TestExtractAPMDependenciesVersion (t * testing.T ) {
202+ t .Run ("Object format with version field" , func (t * testing.T ) {
203+ frontmatter := map [string ]any {
204+ "dependencies" : map [string ]any {
205+ "packages" : []any {"microsoft/apm-sample-package" },
206+ "version" : "v1.0.0" ,
207+ },
208+ }
209+ result := extractAPMDependenciesFromFrontmatter (frontmatter )
210+ require .NotNil (t , result , "Should return non-nil APMDependenciesInfo" )
211+ assert .Equal (t , "v1.0.0" , result .Version , "Version should be extracted from object format" )
212+ })
213+
214+ t .Run ("Array format has no version field" , func (t * testing.T ) {
215+ frontmatter := map [string ]any {
216+ "dependencies" : []any {"microsoft/apm-sample-package" },
217+ }
218+ result := extractAPMDependenciesFromFrontmatter (frontmatter )
219+ require .NotNil (t , result , "Should return non-nil APMDependenciesInfo" )
220+ assert .Empty (t , result .Version , "Version should be empty for array format" )
221+ })
222+
223+ t .Run ("Object format without version uses empty string" , func (t * testing.T ) {
224+ frontmatter := map [string ]any {
225+ "dependencies" : map [string ]any {
226+ "packages" : []any {"microsoft/apm-sample-package" },
227+ },
228+ }
229+ result := extractAPMDependenciesFromFrontmatter (frontmatter )
230+ require .NotNil (t , result , "Should return non-nil APMDependenciesInfo" )
231+ assert .Empty (t , result .Version , "Version should be empty when not specified" )
232+ })
233+ }
234+
201235func TestEngineGetAPMTarget (t * testing.T ) {
202236 tests := []struct {
203237 name string
@@ -253,6 +287,7 @@ func TestGenerateAPMPackStep(t *testing.T) {
253287 "archive: 'true'" ,
254288 "target: copilot" ,
255289 "working-directory: /tmp/gh-aw/apm-workspace" ,
290+ "apm-version: ${{ env.GH_AW_INFO_APM_VERSION }}" ,
256291 },
257292 },
258293 {
@@ -266,6 +301,7 @@ func TestGenerateAPMPackStep(t *testing.T) {
266301 "- microsoft/apm-sample-package" ,
267302 "- github/skills/review" ,
268303 "target: claude" ,
304+ "apm-version: ${{ env.GH_AW_INFO_APM_VERSION }}" ,
269305 },
270306 },
271307 {
@@ -274,6 +310,15 @@ func TestGenerateAPMPackStep(t *testing.T) {
274310 target : "all" ,
275311 expectedContains : []string {
276312 "target: all" ,
313+ "apm-version: ${{ env.GH_AW_INFO_APM_VERSION }}" ,
314+ },
315+ },
316+ {
317+ name : "Custom APM version still uses env var reference in step" ,
318+ apmDeps : & APMDependenciesInfo {Packages : []string {"microsoft/apm-sample-package" }, Version : "v1.0.0" },
319+ target : "copilot" ,
320+ expectedContains : []string {
321+ "apm-version: ${{ env.GH_AW_INFO_APM_VERSION }}" ,
277322 },
278323 },
279324 }
@@ -323,6 +368,7 @@ func TestGenerateAPMRestoreStep(t *testing.T) {
323368 "Restore APM dependencies" ,
324369 "microsoft/apm-action" ,
325370 "bundle: /tmp/gh-aw/apm-bundle/*.tar.gz" ,
371+ "apm-version: ${{ env.GH_AW_INFO_APM_VERSION }}" ,
326372 },
327373 expectedNotContains : []string {"isolated" },
328374 },
@@ -334,6 +380,14 @@ func TestGenerateAPMRestoreStep(t *testing.T) {
334380 "microsoft/apm-action" ,
335381 "bundle: /tmp/gh-aw/apm-bundle/*.tar.gz" ,
336382 "isolated: 'true'" ,
383+ "apm-version: ${{ env.GH_AW_INFO_APM_VERSION }}" ,
384+ },
385+ },
386+ {
387+ name : "Custom APM version still uses env var reference in step" ,
388+ apmDeps : & APMDependenciesInfo {Packages : []string {"microsoft/apm-sample-package" }, Version : "v1.0.0" },
389+ expectedContains : []string {
390+ "apm-version: ${{ env.GH_AW_INFO_APM_VERSION }}" ,
337391 },
338392 },
339393 }
0 commit comments