From a009933a166b022613e1f98c8951bcd3e7ec96b4 Mon Sep 17 00:00:00 2001 From: bagtoad <47394200+BagToad@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:03:50 -0600 Subject: [PATCH 1/3] Add acceptance tests for `release` commands --- acceptance/acceptance_test.go | 12 +++++++-- acceptance/testdata/release/create.txtar | 12 +++++++++ acceptance/testdata/release/list.txtar | 16 ++++++++++++ .../testdata/release/upload-download.txtar | 25 +++++++++++++++++++ acceptance/testdata/release/view.txtar | 16 ++++++++++++ 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 acceptance/testdata/release/create.txtar create mode 100644 acceptance/testdata/release/list.txtar create mode 100644 acceptance/testdata/release/upload-download.txtar create mode 100644 acceptance/testdata/release/view.txtar diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index 3040ce9b2..51e96778a 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -48,8 +48,7 @@ func TestIssues(t *testing.T) { func TestWorkflows(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, "workflow")) @@ -64,6 +63,15 @@ func TestAPI(t *testing.T) { testscript.Run(t, testScriptParamsFor(tsEnv, "api")) } +func TestReleases(t *testing.T) { + var tsEnv testScriptEnv + if err := tsEnv.fromEnv(); err != nil { + t.Fatal(err) + } + + testscript.Run(t, testScriptParamsFor(tsEnv, "release")) +} + func testScriptParamsFor(tsEnv testScriptEnv, command string) testscript.Params { var files []string if tsEnv.script != "" { diff --git a/acceptance/testdata/release/create.txtar b/acceptance/testdata/release/create.txtar new file mode 100644 index 000000000..3bdafe769 --- /dev/null +++ b/acceptance/testdata/release/create.txtar @@ -0,0 +1,12 @@ +# 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 a release in the repo +cd $SCRIPT_NAME-$RANDOM_STRING +exec gh release create v1.2.3 --notes 'awesome release' --latest diff --git a/acceptance/testdata/release/list.txtar b/acceptance/testdata/release/list.txtar new file mode 100644 index 000000000..844b25daa --- /dev/null +++ b/acceptance/testdata/release/list.txtar @@ -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 a release in the repo +cd $SCRIPT_NAME-$RANDOM_STRING +exec gh release create v1.2.3 --notes 'awesome release' --latest + +# List the releases +exec gh release list +stdout 'v1.2.3' \ No newline at end of file diff --git a/acceptance/testdata/release/upload-download.txtar b/acceptance/testdata/release/upload-download.txtar new file mode 100644 index 000000000..92bfa4c71 --- /dev/null +++ b/acceptance/testdata/release/upload-download.txtar @@ -0,0 +1,25 @@ +# 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 a release in the repo +cd $SCRIPT_NAME-$RANDOM_STRING +exec gh release create v1.2.3 --notes 'awesome release' --latest + +# Upload an asset to the release +exec gh release upload v1.2.3 ../asset.txt +stdout '' + +# Download the asset from the release +exec gh release download v1.2.3 +exists asset.txt +exec gh release download v1.2.3 --archive=zip +exists $SCRIPT_NAME-$RANDOM_STRING-1.2.3.zip + +-- asset.txt -- +Hello, world! \ No newline at end of file diff --git a/acceptance/testdata/release/view.txtar b/acceptance/testdata/release/view.txtar new file mode 100644 index 000000000..a7138812a --- /dev/null +++ b/acceptance/testdata/release/view.txtar @@ -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 a release in the repo +cd $SCRIPT_NAME-$RANDOM_STRING +exec gh release create v1.2.3 --notes 'awesome release' --latest + +# View the release +exec gh release view v1.2.3 +stdout 'v1.2.3' \ No newline at end of file From 473faea5739a7b8dfd39740d74c0b83780c18c05 Mon Sep 17 00:00:00 2001 From: bagtoad <47394200+BagToad@users.noreply.github.com> Date: Thu, 17 Oct 2024 07:43:21 -0600 Subject: [PATCH 2/3] Rename test files --- .../testdata/release/{create.txtar => release-create.txtar} | 0 acceptance/testdata/release/{list.txtar => release-list.txtar} | 0 .../{upload-download.txtar => release-upload-download.txtar} | 0 acceptance/testdata/release/{view.txtar => release-view.txtar} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename acceptance/testdata/release/{create.txtar => release-create.txtar} (100%) rename acceptance/testdata/release/{list.txtar => release-list.txtar} (100%) rename acceptance/testdata/release/{upload-download.txtar => release-upload-download.txtar} (100%) rename acceptance/testdata/release/{view.txtar => release-view.txtar} (100%) diff --git a/acceptance/testdata/release/create.txtar b/acceptance/testdata/release/release-create.txtar similarity index 100% rename from acceptance/testdata/release/create.txtar rename to acceptance/testdata/release/release-create.txtar diff --git a/acceptance/testdata/release/list.txtar b/acceptance/testdata/release/release-list.txtar similarity index 100% rename from acceptance/testdata/release/list.txtar rename to acceptance/testdata/release/release-list.txtar diff --git a/acceptance/testdata/release/upload-download.txtar b/acceptance/testdata/release/release-upload-download.txtar similarity index 100% rename from acceptance/testdata/release/upload-download.txtar rename to acceptance/testdata/release/release-upload-download.txtar diff --git a/acceptance/testdata/release/view.txtar b/acceptance/testdata/release/release-view.txtar similarity index 100% rename from acceptance/testdata/release/view.txtar rename to acceptance/testdata/release/release-view.txtar From 24fc2db39590bf92e0ff6df85d8609e33ec48c6f Mon Sep 17 00:00:00 2001 From: William Martin Date: Thu, 17 Oct 2024 15:54:50 +0200 Subject: [PATCH 3/3] Remove stdout assertion from release --- acceptance/testdata/release/release-upload-download.txtar | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/acceptance/testdata/release/release-upload-download.txtar b/acceptance/testdata/release/release-upload-download.txtar index 92bfa4c71..e19bc06d7 100644 --- a/acceptance/testdata/release/release-upload-download.txtar +++ b/acceptance/testdata/release/release-upload-download.txtar @@ -13,13 +13,14 @@ exec gh release create v1.2.3 --notes 'awesome release' --latest # Upload an asset to the release exec gh release upload v1.2.3 ../asset.txt -stdout '' # Download the asset from the release exec gh release download v1.2.3 exists asset.txt + +# Download the asset in archive form exec gh release download v1.2.3 --archive=zip exists $SCRIPT_NAME-$RANDOM_STRING-1.2.3.zip -- asset.txt -- -Hello, world! \ No newline at end of file +Hello, world!