Use stdout2env in PR acceptance tests
This commit is contained in:
parent
37171628c6
commit
464a69ae87
3 changed files with 17 additions and 6 deletions
|
|
@ -58,11 +58,20 @@ var sharedSetup = func(ts *testscript.Env) error {
|
|||
var sharedCmds = map[string]func(ts *testscript.TestScript, neg bool, args []string){
|
||||
"defer": func(ts *testscript.TestScript, neg bool, args []string) {
|
||||
ts.Defer(func() {
|
||||
if err := ts.Exec(args[0], args[1:]...); err != nil {
|
||||
ts.Fatalf("deferred command failed: %v", err)
|
||||
}
|
||||
ts.Check(ts.Exec(args[0], args[1:]...))
|
||||
})
|
||||
}}
|
||||
},
|
||||
"stdout2env": func(ts *testscript.TestScript, neg bool, args []string) {
|
||||
if neg {
|
||||
ts.Fatalf("unsupported: ! stdout2env")
|
||||
}
|
||||
if len(args) != 1 {
|
||||
ts.Fatalf("usage: stdout2env name")
|
||||
}
|
||||
|
||||
ts.Setenv(args[0], strings.TrimRight(ts.ReadFile("stdout"), "\n"))
|
||||
},
|
||||
}
|
||||
|
||||
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
|
||||
|
|
|
|||
3
acceptance/testdata/pr/pr-checkout.txt
vendored
3
acceptance/testdata/pr/pr-checkout.txt
vendored
|
|
@ -18,6 +18,7 @@ exec git push -u origin feature-branch
|
|||
|
||||
# Create the PR
|
||||
exec gh pr create --title 'Feature Title' --body 'Feature Body'
|
||||
stdout2env PR_URL
|
||||
|
||||
# Remove the local branch
|
||||
exec git checkout main
|
||||
|
|
@ -25,5 +26,5 @@ exec git branch -D feature-branch
|
|||
stdout 'Deleted branch feature-branch'
|
||||
|
||||
# Checkout the PR
|
||||
exec gh pr checkout 1
|
||||
exec gh pr checkout $PR_URL
|
||||
stderr 'Switched to a new branch ''feature-branch'''
|
||||
|
|
|
|||
3
acceptance/testdata/pr/pr-view.txt
vendored
3
acceptance/testdata/pr/pr-view.txt
vendored
|
|
@ -18,7 +18,8 @@ exec git push -u origin feature-branch
|
|||
|
||||
# Create the PR
|
||||
exec gh pr create --title 'Feature Title' --body 'Feature Body'
|
||||
stdout2env PR_URL
|
||||
|
||||
# View the PR
|
||||
exec gh pr view 1
|
||||
exec gh pr view $PR_URL
|
||||
stdout 'Feature Title'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue