Merge pull request #9757 from cli/wm/testscript-issues
Add Acceptance tests for `issue` command
This commit is contained in:
commit
a6974cc8d6
6 changed files with 100 additions and 3 deletions
|
|
@ -28,8 +28,16 @@ func TestMain(m *testing.M) {
|
|||
func TestPullRequests(t *testing.T) {
|
||||
var tsEnv testScriptEnv
|
||||
if err := tsEnv.fromEnv(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
testscript.Run(t, testScriptParamsFor(tsEnv, "pr"))
|
||||
}
|
||||
|
||||
func TestIssues(t *testing.T) {
|
||||
var tsEnv testScriptEnv
|
||||
if err := tsEnv.fromEnv(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
testscript.Run(t, testScriptParamsFor(tsEnv, "pr"))
|
||||
|
|
@ -147,7 +155,7 @@ type missingEnvError struct {
|
|||
}
|
||||
|
||||
func (e missingEnvError) Error() string {
|
||||
return fmt.Sprintf("environment variables %s must be set and non-empty", strings.Join(e.missingEnvs, ", "))
|
||||
return fmt.Sprintf("environment variable(s) %s must be set and non-empty", strings.Join(e.missingEnvs, ", "))
|
||||
}
|
||||
|
||||
type testScriptEnv struct {
|
||||
|
|
|
|||
20
acceptance/testdata/issue/issue-comment.txtar
vendored
Normal file
20
acceptance/testdata/issue/issue-comment.txtar
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Create a repository with a file so it has a default branch
|
||||
exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private
|
||||
|
||||
# Defer repo cleanup
|
||||
defer gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING
|
||||
|
||||
# Clone the repo
|
||||
exec gh repo clone $ORG/$SCRIPT_NAME-$RANDOM_STRING
|
||||
|
||||
# Create an issue in the repo
|
||||
cd $SCRIPT_NAME-$RANDOM_STRING
|
||||
exec gh issue create --title 'Feature Request' --body 'Feature Body'
|
||||
stdout2env ISSUE_URL
|
||||
|
||||
# Comment on the issue
|
||||
exec gh issue comment $ISSUE_URL --body 'Looks like a great feature!'
|
||||
|
||||
# View the issue
|
||||
exec gh issue view $ISSUE_URL --comments
|
||||
stdout 'Looks like a great feature!'
|
||||
17
acceptance/testdata/issue/issue-create-basic.txtar
vendored
Normal file
17
acceptance/testdata/issue/issue-create-basic.txtar
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Create a repository with a file so it has a default branch
|
||||
exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private
|
||||
|
||||
# Defer repo cleanup
|
||||
defer gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING
|
||||
|
||||
# Clone the repo
|
||||
exec gh repo clone $ORG/$SCRIPT_NAME-$RANDOM_STRING
|
||||
|
||||
# Create an issue in the repo
|
||||
cd $SCRIPT_NAME-$RANDOM_STRING
|
||||
exec gh issue create --title 'Feature Request' --body 'Feature Body'
|
||||
stdout2env ISSUE_URL
|
||||
|
||||
# Check the issue was created
|
||||
exec gh issue view $ISSUE_URL
|
||||
stdout 'title:\tFeature Request$'
|
||||
19
acceptance/testdata/issue/issue-create-with-metadata.txtar
vendored
Normal file
19
acceptance/testdata/issue/issue-create-with-metadata.txtar
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Create a repository with a file so it has a default branch
|
||||
exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private
|
||||
|
||||
# Defer repo cleanup
|
||||
defer gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING
|
||||
|
||||
# Clone the repo
|
||||
exec gh repo clone $ORG/$SCRIPT_NAME-$RANDOM_STRING
|
||||
|
||||
# Create an issue in the repo
|
||||
cd $SCRIPT_NAME-$RANDOM_STRING
|
||||
exec gh issue create --title 'Feature Request' --body 'Feature Body' --assignee '@me' --label 'bug'
|
||||
stdout2env ISSUE_URL
|
||||
|
||||
# Check the issue was create
|
||||
exec gh issue view $ISSUE_URL
|
||||
stdout 'title:\tFeature Request$'
|
||||
stdout 'assignees:\t.+$'
|
||||
stdout 'labels:\tbug$'
|
||||
16
acceptance/testdata/issue/issue-list.txtar
vendored
Normal file
16
acceptance/testdata/issue/issue-list.txtar
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Create a repository with a file so it has a default branch
|
||||
exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private
|
||||
|
||||
# Defer repo cleanup
|
||||
defer gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING
|
||||
|
||||
# Clone the repo
|
||||
exec gh repo clone $ORG/$SCRIPT_NAME-$RANDOM_STRING
|
||||
|
||||
# Create an issue in the repo
|
||||
cd $SCRIPT_NAME-$RANDOM_STRING
|
||||
exec gh issue create --title 'Feature Request' --body 'Feature Body'
|
||||
|
||||
# Check the issue is included in the list output
|
||||
exec gh issue list
|
||||
stdout 'OPEN\tFeature Request'
|
||||
17
acceptance/testdata/issue/issue-view.txtar
vendored
Normal file
17
acceptance/testdata/issue/issue-view.txtar
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Create a repository with a file so it has a default branch
|
||||
exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private
|
||||
|
||||
# Defer repo cleanup
|
||||
defer gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING
|
||||
|
||||
# Clone the repo
|
||||
exec gh repo clone $ORG/$SCRIPT_NAME-$RANDOM_STRING
|
||||
|
||||
# Create an issue in the repo
|
||||
cd $SCRIPT_NAME-$RANDOM_STRING
|
||||
exec gh issue create --title 'Feature Request' --body 'Feature Body'
|
||||
stdout2env ISSUE_URL
|
||||
|
||||
# Check the issue was created
|
||||
exec gh issue view $ISSUE_URL
|
||||
stdout 'title:\tFeature Request$'
|
||||
Loading…
Add table
Add a link
Reference in a new issue