Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions pkg/workflow/create_pull_request_cross_repo_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ Create a pull request in a different repository.

compiledContent := string(compiledBytes)

// Test 1: Verify repository parameter is set in actions/checkout
assert.Contains(t, compiledContent, "repository: microsoft/vscode-docs",
"Expected checkout to specify target repository")
// Test 1: Verify target-repo is propagated to the safe-outputs handler config
assert.Contains(t, compiledContent, `"target-repo":"microsoft/vscode-docs"`,
"Expected target-repo to be included in safe-outputs handler config")
Comment on lines +56 to +58

// Test 2: Verify GITHUB_REPOSITORY environment variable is set to target repo
assert.Contains(t, compiledContent, `GITHUB_REPOSITORY: "microsoft/vscode-docs"`,
"Expected GITHUB_REPOSITORY env var to be set to target repository")
// Test 2: Verify checkout remains a default workspace checkout (no explicit cross-repo checkout)
checkoutSection := extractCheckoutSection(compiledContent)
assert.NotContains(t, checkoutSection, "repository:",
"Checkout section should not have explicit repository when using default workspace checkout")

// Test 3: Verify token is included for cross-repo checkout
assert.Contains(t, compiledContent, "token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}",
"Expected token to be set for cross-repo checkout")
// Test 3: Verify checkout does not inject a dedicated token for target-repo
assert.NotContains(t, checkoutSection, "token:",
"Checkout section should not have an explicit token for target-repo")

// Test 4: Verify it does NOT use the default github.repository
checkoutSection := extractCheckoutSection(compiledContent)
assert.NotContains(t, checkoutSection, "github.repository",
"Checkout section should not reference github.repository when target-repo is set")
// Test 4: Verify GITHUB_REPOSITORY remains the source repository expression
assert.Contains(t, compiledContent, "GITHUB_REPOSITORY: ${{ github.repository }}",
"Expected GITHUB_REPOSITORY to remain github.repository expression")
}

// TestCreatePullRequestSameRepoCheckout tests that without target-repo, we use default checkout
Expand Down