From b361cf4495230fb9f348622b59551ab22be286c3 Mon Sep 17 00:00:00 2001 From: bagtoad <47394200+BagToad@users.noreply.github.com> Date: Fri, 18 Oct 2024 10:17:34 -0600 Subject: [PATCH 1/2] Implement acceptance tests for search commands --- acceptance/acceptance_test.go | 9 +++++++++ .../testdata/search/search-issues.txtar | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 acceptance/testdata/search/search-issues.txtar diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index 51e96778a..750dadd76 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -72,6 +72,15 @@ func TestReleases(t *testing.T) { testscript.Run(t, testScriptParamsFor(tsEnv, "release")) } +func TestSearches(t *testing.T) { + var tsEnv testScriptEnv + if err := tsEnv.fromEnv(); err != nil { + t.Fatal(err) + } + + testscript.Run(t, testScriptParamsFor(tsEnv, "search")) +} + func testScriptParamsFor(tsEnv testScriptEnv, command string) testscript.Params { var files []string if tsEnv.script != "" { diff --git a/acceptance/testdata/search/search-issues.txtar b/acceptance/testdata/search/search-issues.txtar new file mode 100644 index 000000000..e41bc1eb6 --- /dev/null +++ b/acceptance/testdata/search/search-issues.txtar @@ -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 $RANDOM_STRING' + +# It takes some time for the issue to be created and indexed +sleep 5 + +# Search for the issue +exec gh search issues 'Feature Body $RANDOM_STRING' -R $ORG/$SCRIPT_NAME-$RANDOM_STRING +stdout 'Feature Request' \ No newline at end of file From 1736de2cd10f5c3da582edc789cbbcd213cb989b Mon Sep 17 00:00:00 2001 From: bagtoad <47394200+BagToad@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:20:37 -0600 Subject: [PATCH 2/2] Fix single quote not expanding vars --- acceptance/testdata/search/search-issues.txtar | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/acceptance/testdata/search/search-issues.txtar b/acceptance/testdata/search/search-issues.txtar index e41bc1eb6..82184f3f1 100644 --- a/acceptance/testdata/search/search-issues.txtar +++ b/acceptance/testdata/search/search-issues.txtar @@ -9,11 +9,12 @@ 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 $RANDOM_STRING' + +exec gh issue create --title 'Feature Request' --body $RANDOM_STRING # It takes some time for the issue to be created and indexed sleep 5 # Search for the issue -exec gh search issues 'Feature Body $RANDOM_STRING' -R $ORG/$SCRIPT_NAME-$RANDOM_STRING -stdout 'Feature Request' \ No newline at end of file +exec gh search issues $RANDOM_STRING -R $ORG/$SCRIPT_NAME-$RANDOM_STRING +stdout $RANDOM_STRING \ No newline at end of file