From 18428671c3795504d15d8fa01199db595c2d3c0e Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Wed, 16 Oct 2024 15:14:18 -0700 Subject: [PATCH 01/16] Added test function for repos and repo-create test --- acceptance/acceptance_test.go | 8 ++++++++ acceptance/testdata/repos/repo-create-view.txtar | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 acceptance/testdata/repos/repo-create-view.txtar diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index 51e96778a..366d88cf4 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -72,6 +72,14 @@ func TestReleases(t *testing.T) { testscript.Run(t, testScriptParamsFor(tsEnv, "release")) } +func TestRepos(t *testing.T) { + var tsEnv testScriptEnv + if err := tsEnv.fromEnv(); err != nil { + t.Fatal(err) + } + testscript.Run(t, testScriptParamsFor(tsEnv, "repos")) +} + func testScriptParamsFor(tsEnv testScriptEnv, command string) testscript.Params { var files []string if tsEnv.script != "" { diff --git a/acceptance/testdata/repos/repo-create-view.txtar b/acceptance/testdata/repos/repo-create-view.txtar new file mode 100644 index 000000000..b5b85f593 --- /dev/null +++ b/acceptance/testdata/repos/repo-create-view.txtar @@ -0,0 +1,12 @@ +# Use gh as a credential helper +exec gh auth setup-git + +# 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 + +# Check that the repo exists +exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json name --jq '.name' +stdout $SCRIPT_NAME-$RANDOM_STRING \ No newline at end of file From 83cbdc4f3686cbfd1500ce71820d2e23997bcdee Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Wed, 16 Oct 2024 15:28:38 -0700 Subject: [PATCH 02/16] Added acceptance test for repo-delete --- acceptance/testdata/repos/repo-delete.txtar | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 acceptance/testdata/repos/repo-delete.txtar diff --git a/acceptance/testdata/repos/repo-delete.txtar b/acceptance/testdata/repos/repo-delete.txtar new file mode 100644 index 000000000..855473ae9 --- /dev/null +++ b/acceptance/testdata/repos/repo-delete.txtar @@ -0,0 +1,16 @@ +# Use gh as a credential helper +exec gh auth setup-git + +# Create a repository with a file so it has a default branch +exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private + +# Check that the repo exists +exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json name --jq '.name' +stdout $SCRIPT_NAME-$RANDOM_STRING + +# Delete the repo +exec gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING + +# Ensure that the repo was deleted +! exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json name --jq '.name' +stderr 'Could not resolve to a Repository with the name' \ No newline at end of file From 60e20ee5312b4caa9ce3e98b633bf974b949b863 Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Thu, 17 Oct 2024 08:51:51 -0700 Subject: [PATCH 03/16] Add acceptance test for repo-clone --- acceptance/testdata/repos/repo-clone.txtar | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 acceptance/testdata/repos/repo-clone.txtar diff --git a/acceptance/testdata/repos/repo-clone.txtar b/acceptance/testdata/repos/repo-clone.txtar new file mode 100644 index 000000000..f0bad8e01 --- /dev/null +++ b/acceptance/testdata/repos/repo-clone.txtar @@ -0,0 +1,15 @@ +# Use gh as a credential helper +exec gh auth setup-git + +# 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 + +# Ensure the repo was cloned +exec ls $SCRIPT_NAME-$RANDOM_STRING +stdout README.md \ No newline at end of file From 0c632d7c4eada9577449921c87c2cb7c340b9071 Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Thu, 17 Oct 2024 09:43:50 -0700 Subject: [PATCH 04/16] Acceptance testing for repo-archive and repo-unarchive --- .../repos/repo-archive-unarchive.txtar | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 acceptance/testdata/repos/repo-archive-unarchive.txtar diff --git a/acceptance/testdata/repos/repo-archive-unarchive.txtar b/acceptance/testdata/repos/repo-archive-unarchive.txtar new file mode 100644 index 000000000..d72b36906 --- /dev/null +++ b/acceptance/testdata/repos/repo-archive-unarchive.txtar @@ -0,0 +1,26 @@ +# Use gh as a credential helper +exec gh auth setup-git + +# 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 + +# Check that the repo exists and isn't archived +exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=isArchived --jq='.isArchived' +stdout false + +# Archive the repo +exec gh repo archive $ORG/$SCRIPT_NAME-$RANDOM_STRING --yes + +# Check that the repo is archived +exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=isArchived --jq='.isArchived' +stdout true + +# Unarchive the repo +exec gh repo unarchive $ORG/$SCRIPT_NAME-$RANDOM_STRING --yes + +# Check that the repo is unarchived +exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=isArchived --jq='.isArchived' +stdout false \ No newline at end of file From fb6f7733c4974524b25d6b7d66075e0d002a8a8c Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Thu, 17 Oct 2024 09:58:59 -0700 Subject: [PATCH 05/16] Add acceptance tests for repo-list and repo-rename --- .../testdata/repos/repo-list-rename.txtar | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 acceptance/testdata/repos/repo-list-rename.txtar diff --git a/acceptance/testdata/repos/repo-list-rename.txtar b/acceptance/testdata/repos/repo-list-rename.txtar new file mode 100644 index 000000000..e758ac7fd --- /dev/null +++ b/acceptance/testdata/repos/repo-list-rename.txtar @@ -0,0 +1,24 @@ +# Use gh as a credential helper +exec gh auth setup-git + +# Create a repository with a file so it has a default branch +exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private + +# List the repos and check for the new repo +exec gh repo list $ORG --json name --jq '.[].name' +stdout $SCRIPT_NAME-$RANDOM_STRING + +# Rename the repo +exec gh repo rename $SCRIPT_NAME-$RANDOM_STRING-renamed --repo=$ORG/$SCRIPT_NAME-$RANDOM_STRING --yes + +# List the repos and check for the renamed repo +exec gh repo list $ORG --json name --jq '.[].name' +stdout $SCRIPT_NAME-$RANDOM_STRING-renamed + +# Delete the renamed repo +exec gh repo delete $ORG/$SCRIPT_NAME-$RANDOM_STRING-renamed --yes + +# List the repos and check for the deleted repo +exec gh repo list $ORG --json name --jq '.[].name' +! stdout $SCRIPT_NAME-$RANDOM_STRING-renamed + From c572edbfd797780426def51559b3e0fece1ff59e Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Thu, 17 Oct 2024 10:08:14 -0700 Subject: [PATCH 06/16] Add acceptance test for repo-edit --- acceptance/testdata/repos/repo-edit.txtar | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 acceptance/testdata/repos/repo-edit.txtar diff --git a/acceptance/testdata/repos/repo-edit.txtar b/acceptance/testdata/repos/repo-edit.txtar new file mode 100644 index 000000000..c8e293cc0 --- /dev/null +++ b/acceptance/testdata/repos/repo-edit.txtar @@ -0,0 +1,19 @@ +# Use gh as a credential helper +exec gh auth setup-git + +# 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 + +# Check that the repo description is empty +exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json description --jq '.description' +stdout '' + +# Edit the repo description +exec gh repo edit $ORG/$SCRIPT_NAME-$RANDOM_STRING --description 'newDescription' + +# Check that the repo description is updated +exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json description --jq '.description' +stdout 'newDescription' \ No newline at end of file From 750813135635b79c99ac292414e22f7d56cb7bb0 Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Thu, 17 Oct 2024 10:27:20 -0700 Subject: [PATCH 07/16] Add acceptance test for repo-set-default --- .../testdata/repos/repo-set-default.txtar | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 acceptance/testdata/repos/repo-set-default.txtar diff --git a/acceptance/testdata/repos/repo-set-default.txtar b/acceptance/testdata/repos/repo-set-default.txtar new file mode 100644 index 000000000..f8c0e68c5 --- /dev/null +++ b/acceptance/testdata/repos/repo-set-default.txtar @@ -0,0 +1,23 @@ +# Use gh as a credential helper +exec gh auth setup-git + +# 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 +cd $SCRIPT_NAME-$RANDOM_STRING + +# Ensure that no default is set +exec gh repo set-default --view +stderr 'no default repository has been set; use `gh repo set-default` to select one' + +# Set the default +exec gh repo set-default $ORG/$SCRIPT_NAME-$RANDOM_STRING + +# Check that the default is set +exec gh repo set-default --view +stdout $ORG/$SCRIPT_NAME-$RANDOM_STRING \ No newline at end of file From 96fa8534daa9832b34fa42d432e66298e2fd62a4 Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Thu, 17 Oct 2024 10:55:28 -0700 Subject: [PATCH 08/16] Add acceptance tests for repo-fork and repo-sync --- .../testdata/repos/repo-fork-sync.txtar | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 acceptance/testdata/repos/repo-fork-sync.txtar diff --git a/acceptance/testdata/repos/repo-fork-sync.txtar b/acceptance/testdata/repos/repo-fork-sync.txtar new file mode 100644 index 000000000..73beb39f1 --- /dev/null +++ b/acceptance/testdata/repos/repo-fork-sync.txtar @@ -0,0 +1,44 @@ +# Use gh as a credential helper +exec gh auth setup-git + +# Create and clone a repository with a file so it has a default branch +exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private --clone + +# Defer repo cleanup +defer gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING + +# Fork and clone the repo +exec gh repo fork $ORG/$SCRIPT_NAME-$RANDOM_STRING --org $ORG --fork-name $SCRIPT_NAME-$RANDOM_STRING-fork --clone + +# Defer fork cleanup +defer gh repo delete $ORG/$SCRIPT_NAME-$RANDOM_STRING-fork --yes + +# Sleep so that the BE has time to sync +sleep 5 + +# Check that the repo was forked +exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING-fork --json='isFork' --jq='.isFork' +stdout true + +# Modify original repo +cd $SCRIPT_NAME-$RANDOM_STRING +mv ../asset.txt asset.txt +exec git add . +exec git commit -m 'Add asset.txt' +exec git push + +# Checkout the forked repo and ensure asset.txt is not present +cd ../$SCRIPT_NAME-$RANDOM_STRING-fork +exec git checkout main +exec ls +! stdout asset.txt + +# Sync the forked repo with the original repo +exec gh repo sync + +# Check that asset.txt now exists in the fork +exec ls +stdout asset.txt + +-- asset.txt -- +Hello, world! \ No newline at end of file From 95ed11d9babcd3dfa41d4e1d345ef343888078d7 Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Thu, 17 Oct 2024 11:55:32 -0700 Subject: [PATCH 09/16] Add acceptance tests for repo deploy-key add/list/delete --- .../testdata/repos/repo-deploy-key.txtar | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 acceptance/testdata/repos/repo-deploy-key.txtar diff --git a/acceptance/testdata/repos/repo-deploy-key.txtar b/acceptance/testdata/repos/repo-deploy-key.txtar new file mode 100644 index 000000000..69c2efef8 --- /dev/null +++ b/acceptance/testdata/repos/repo-deploy-key.txtar @@ -0,0 +1,35 @@ +# Use gh as a credential helper +exec gh auth setup-git + +# Create and clone a repository with a file so it has a default branch +exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private --clone + +# Defer repo cleanup +defer gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING + +# cd to the repo and list the deploy keys. There should be no keys +cd $SCRIPT_NAME-$RANDOM_STRING +exec gh repo deploy-key list --json=title +! stdout title + +# Add a deploy key +exec gh repo deploy-key add ../deployKey.pub + +# Ensure the deploy key was added +exec gh repo deploy-key list --json=title --jq='.[].title' +stdout myTitle + +# Get the deploy key id +exec gh repo deploy-key list --json=title,id --jq='.[].title="myTitle" | .[].id' +stdout2env DEPLOY_KEY_ID + +# Delete the deploy key +exec gh repo deploy-key delete $DEPLOY_KEY_ID + +# Ensure the deploy key was deleted +exec gh repo deploy-key list --json=id --jq='.[].id' +! stdout $DEPLOY_KEY_ID + +-- deployKey.pub -- +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAZmdeRNskfpvYL5YHB/YJaW8hTEXpnvPMkx5Ri+YwUr myTitle + From e7549c93f9c4069b30173320b007ca330ee9161d Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Thu, 17 Oct 2024 13:36:19 -0700 Subject: [PATCH 10/16] Cleanup some inconsistencies and improve collapse some functionality --- .../testdata/repos/repo-archive-unarchive.txtar | 2 +- acceptance/testdata/repos/repo-clone.txtar | 2 +- acceptance/testdata/repos/repo-create-view.txtar | 4 ++-- acceptance/testdata/repos/repo-delete.txtar | 2 +- acceptance/testdata/repos/repo-deploy-key.txtar | 1 - acceptance/testdata/repos/repo-edit.txtar | 4 ++-- acceptance/testdata/repos/repo-fork-sync.txtar | 2 +- acceptance/testdata/repos/repo-list-rename.txtar | 15 +++++---------- acceptance/testdata/repos/repo-set-default.txtar | 11 ++++------- 9 files changed, 17 insertions(+), 26 deletions(-) diff --git a/acceptance/testdata/repos/repo-archive-unarchive.txtar b/acceptance/testdata/repos/repo-archive-unarchive.txtar index d72b36906..de1f7df9f 100644 --- a/acceptance/testdata/repos/repo-archive-unarchive.txtar +++ b/acceptance/testdata/repos/repo-archive-unarchive.txtar @@ -23,4 +23,4 @@ exec gh repo unarchive $ORG/$SCRIPT_NAME-$RANDOM_STRING --yes # Check that the repo is unarchived exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=isArchived --jq='.isArchived' -stdout false \ No newline at end of file +stdout false diff --git a/acceptance/testdata/repos/repo-clone.txtar b/acceptance/testdata/repos/repo-clone.txtar index f0bad8e01..5afc3ab0e 100644 --- a/acceptance/testdata/repos/repo-clone.txtar +++ b/acceptance/testdata/repos/repo-clone.txtar @@ -12,4 +12,4 @@ exec gh repo clone $ORG/$SCRIPT_NAME-$RANDOM_STRING # Ensure the repo was cloned exec ls $SCRIPT_NAME-$RANDOM_STRING -stdout README.md \ No newline at end of file +stdout README.md diff --git a/acceptance/testdata/repos/repo-create-view.txtar b/acceptance/testdata/repos/repo-create-view.txtar index b5b85f593..f1a67ac73 100644 --- a/acceptance/testdata/repos/repo-create-view.txtar +++ b/acceptance/testdata/repos/repo-create-view.txtar @@ -8,5 +8,5 @@ exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private defer gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING # Check that the repo exists -exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json name --jq '.name' -stdout $SCRIPT_NAME-$RANDOM_STRING \ No newline at end of file +exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=name --jq='.name' +stdout $SCRIPT_NAME-$RANDOM_STRING diff --git a/acceptance/testdata/repos/repo-delete.txtar b/acceptance/testdata/repos/repo-delete.txtar index 855473ae9..c9fd2c058 100644 --- a/acceptance/testdata/repos/repo-delete.txtar +++ b/acceptance/testdata/repos/repo-delete.txtar @@ -13,4 +13,4 @@ exec gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING # Ensure that the repo was deleted ! exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json name --jq '.name' -stderr 'Could not resolve to a Repository with the name' \ No newline at end of file +stderr 'Could not resolve to a Repository with the name' diff --git a/acceptance/testdata/repos/repo-deploy-key.txtar b/acceptance/testdata/repos/repo-deploy-key.txtar index 69c2efef8..42c5b1746 100644 --- a/acceptance/testdata/repos/repo-deploy-key.txtar +++ b/acceptance/testdata/repos/repo-deploy-key.txtar @@ -32,4 +32,3 @@ exec gh repo deploy-key list --json=id --jq='.[].id' -- deployKey.pub -- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAZmdeRNskfpvYL5YHB/YJaW8hTEXpnvPMkx5Ri+YwUr myTitle - diff --git a/acceptance/testdata/repos/repo-edit.txtar b/acceptance/testdata/repos/repo-edit.txtar index c8e293cc0..3fd5a48f6 100644 --- a/acceptance/testdata/repos/repo-edit.txtar +++ b/acceptance/testdata/repos/repo-edit.txtar @@ -9,11 +9,11 @@ defer gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING # Check that the repo description is empty exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json description --jq '.description' -stdout '' +! stdout '.' # Edit the repo description exec gh repo edit $ORG/$SCRIPT_NAME-$RANDOM_STRING --description 'newDescription' # Check that the repo description is updated exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json description --jq '.description' -stdout 'newDescription' \ No newline at end of file +stdout 'newDescription' diff --git a/acceptance/testdata/repos/repo-fork-sync.txtar b/acceptance/testdata/repos/repo-fork-sync.txtar index 73beb39f1..8bc437567 100644 --- a/acceptance/testdata/repos/repo-fork-sync.txtar +++ b/acceptance/testdata/repos/repo-fork-sync.txtar @@ -41,4 +41,4 @@ exec ls stdout asset.txt -- asset.txt -- -Hello, world! \ No newline at end of file +Hello, world! diff --git a/acceptance/testdata/repos/repo-list-rename.txtar b/acceptance/testdata/repos/repo-list-rename.txtar index e758ac7fd..972e5a74a 100644 --- a/acceptance/testdata/repos/repo-list-rename.txtar +++ b/acceptance/testdata/repos/repo-list-rename.txtar @@ -5,20 +5,15 @@ exec gh auth setup-git exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private # List the repos and check for the new repo -exec gh repo list $ORG --json name --jq '.[].name' +exec gh repo list $ORG --json=name --jq='.[].name' stdout $SCRIPT_NAME-$RANDOM_STRING # Rename the repo exec gh repo rename $SCRIPT_NAME-$RANDOM_STRING-renamed --repo=$ORG/$SCRIPT_NAME-$RANDOM_STRING --yes +# Defer repo deletion +defer gh repo delete $ORG/$SCRIPT_NAME-$RANDOM_STRING-renamed --yes + # List the repos and check for the renamed repo -exec gh repo list $ORG --json name --jq '.[].name' +exec gh repo list $ORG --json=name --jq='.[].name' stdout $SCRIPT_NAME-$RANDOM_STRING-renamed - -# Delete the renamed repo -exec gh repo delete $ORG/$SCRIPT_NAME-$RANDOM_STRING-renamed --yes - -# List the repos and check for the deleted repo -exec gh repo list $ORG --json name --jq '.[].name' -! stdout $SCRIPT_NAME-$RANDOM_STRING-renamed - diff --git a/acceptance/testdata/repos/repo-set-default.txtar b/acceptance/testdata/repos/repo-set-default.txtar index f8c0e68c5..c5b16b9ac 100644 --- a/acceptance/testdata/repos/repo-set-default.txtar +++ b/acceptance/testdata/repos/repo-set-default.txtar @@ -1,17 +1,14 @@ # Use gh as a credential helper exec gh auth setup-git -# Create a repository with a file so it has a default branch -exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private +# Create and clone a repository with a file so it has a default branch +exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private --clone # 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 -cd $SCRIPT_NAME-$RANDOM_STRING - # Ensure that no default is set +cd $SCRIPT_NAME-$RANDOM_STRING exec gh repo set-default --view stderr 'no default repository has been set; use `gh repo set-default` to select one' @@ -20,4 +17,4 @@ exec gh repo set-default $ORG/$SCRIPT_NAME-$RANDOM_STRING # Check that the default is set exec gh repo set-default --view -stdout $ORG/$SCRIPT_NAME-$RANDOM_STRING \ No newline at end of file +stdout $ORG/$SCRIPT_NAME-$RANDOM_STRING From a5a77532dfd13162c89cad201eba92e0329df82e Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Fri, 18 Oct 2024 08:40:33 -0700 Subject: [PATCH 11/16] Remove unnecessary gh auth setup-git steps --- acceptance/testdata/repos/repo-archive-unarchive.txtar | 3 --- acceptance/testdata/repos/repo-clone.txtar | 3 --- acceptance/testdata/repos/repo-create-view.txtar | 3 --- acceptance/testdata/repos/repo-delete.txtar | 3 --- acceptance/testdata/repos/repo-deploy-key.txtar | 3 --- acceptance/testdata/repos/repo-edit.txtar | 3 --- acceptance/testdata/repos/repo-list-rename.txtar | 3 --- acceptance/testdata/repos/repo-set-default.txtar | 3 --- 8 files changed, 24 deletions(-) diff --git a/acceptance/testdata/repos/repo-archive-unarchive.txtar b/acceptance/testdata/repos/repo-archive-unarchive.txtar index de1f7df9f..79122a80c 100644 --- a/acceptance/testdata/repos/repo-archive-unarchive.txtar +++ b/acceptance/testdata/repos/repo-archive-unarchive.txtar @@ -1,6 +1,3 @@ -# Use gh as a credential helper -exec gh auth setup-git - # Create a repository with a file so it has a default branch exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private diff --git a/acceptance/testdata/repos/repo-clone.txtar b/acceptance/testdata/repos/repo-clone.txtar index 5afc3ab0e..f08953be1 100644 --- a/acceptance/testdata/repos/repo-clone.txtar +++ b/acceptance/testdata/repos/repo-clone.txtar @@ -1,6 +1,3 @@ -# Use gh as a credential helper -exec gh auth setup-git - # Create a repository with a file so it has a default branch exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private diff --git a/acceptance/testdata/repos/repo-create-view.txtar b/acceptance/testdata/repos/repo-create-view.txtar index f1a67ac73..9774def35 100644 --- a/acceptance/testdata/repos/repo-create-view.txtar +++ b/acceptance/testdata/repos/repo-create-view.txtar @@ -1,6 +1,3 @@ -# Use gh as a credential helper -exec gh auth setup-git - # Create a repository with a file so it has a default branch exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private diff --git a/acceptance/testdata/repos/repo-delete.txtar b/acceptance/testdata/repos/repo-delete.txtar index c9fd2c058..2e0bbc62a 100644 --- a/acceptance/testdata/repos/repo-delete.txtar +++ b/acceptance/testdata/repos/repo-delete.txtar @@ -1,6 +1,3 @@ -# Use gh as a credential helper -exec gh auth setup-git - # Create a repository with a file so it has a default branch exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private diff --git a/acceptance/testdata/repos/repo-deploy-key.txtar b/acceptance/testdata/repos/repo-deploy-key.txtar index 42c5b1746..d93d07ee5 100644 --- a/acceptance/testdata/repos/repo-deploy-key.txtar +++ b/acceptance/testdata/repos/repo-deploy-key.txtar @@ -1,6 +1,3 @@ -# Use gh as a credential helper -exec gh auth setup-git - # Create and clone a repository with a file so it has a default branch exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private --clone diff --git a/acceptance/testdata/repos/repo-edit.txtar b/acceptance/testdata/repos/repo-edit.txtar index 3fd5a48f6..00d3cdd2c 100644 --- a/acceptance/testdata/repos/repo-edit.txtar +++ b/acceptance/testdata/repos/repo-edit.txtar @@ -1,6 +1,3 @@ -# Use gh as a credential helper -exec gh auth setup-git - # Create a repository with a file so it has a default branch exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private diff --git a/acceptance/testdata/repos/repo-list-rename.txtar b/acceptance/testdata/repos/repo-list-rename.txtar index 972e5a74a..7f3ff1281 100644 --- a/acceptance/testdata/repos/repo-list-rename.txtar +++ b/acceptance/testdata/repos/repo-list-rename.txtar @@ -1,6 +1,3 @@ -# Use gh as a credential helper -exec gh auth setup-git - # Create a repository with a file so it has a default branch exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private diff --git a/acceptance/testdata/repos/repo-set-default.txtar b/acceptance/testdata/repos/repo-set-default.txtar index c5b16b9ac..4f7fa3273 100644 --- a/acceptance/testdata/repos/repo-set-default.txtar +++ b/acceptance/testdata/repos/repo-set-default.txtar @@ -1,6 +1,3 @@ -# Use gh as a credential helper -exec gh auth setup-git - # Create and clone a repository with a file so it has a default branch exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private --clone From ee0d9ab901843a9bd106395928a627b77af63731 Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Fri, 18 Oct 2024 08:44:36 -0700 Subject: [PATCH 12/16] Wrap boolean strings in '' so it is clear they are strings --- acceptance/testdata/repos/repo-archive-unarchive.txtar | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/acceptance/testdata/repos/repo-archive-unarchive.txtar b/acceptance/testdata/repos/repo-archive-unarchive.txtar index 79122a80c..33ff519f3 100644 --- a/acceptance/testdata/repos/repo-archive-unarchive.txtar +++ b/acceptance/testdata/repos/repo-archive-unarchive.txtar @@ -6,18 +6,18 @@ defer gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING # Check that the repo exists and isn't archived exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=isArchived --jq='.isArchived' -stdout false +stdout 'false' # Archive the repo exec gh repo archive $ORG/$SCRIPT_NAME-$RANDOM_STRING --yes # Check that the repo is archived exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=isArchived --jq='.isArchived' -stdout true +stdout 'true' # Unarchive the repo exec gh repo unarchive $ORG/$SCRIPT_NAME-$RANDOM_STRING --yes # Check that the repo is unarchived exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=isArchived --jq='.isArchived' -stdout false +stdout 'false' From 25f2956e671721a153ded1822f2e11be0644b4e3 Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Fri, 18 Oct 2024 08:45:02 -0700 Subject: [PATCH 13/16] Replace LICENSE Makefile README.md acceptance api bin build cmd context docs git go.mod go.sum internal pkg script share test utils commands with --- acceptance/testdata/repos/repo-clone.txtar | 3 +-- acceptance/testdata/repos/repo-fork-sync.txtar | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/acceptance/testdata/repos/repo-clone.txtar b/acceptance/testdata/repos/repo-clone.txtar index f08953be1..b90a0894b 100644 --- a/acceptance/testdata/repos/repo-clone.txtar +++ b/acceptance/testdata/repos/repo-clone.txtar @@ -8,5 +8,4 @@ defer gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING exec gh repo clone $ORG/$SCRIPT_NAME-$RANDOM_STRING # Ensure the repo was cloned -exec ls $SCRIPT_NAME-$RANDOM_STRING -stdout README.md +exists $SCRIPT_NAME-$RANDOM_STRING/README.md diff --git a/acceptance/testdata/repos/repo-fork-sync.txtar b/acceptance/testdata/repos/repo-fork-sync.txtar index 8bc437567..5b2362ffe 100644 --- a/acceptance/testdata/repos/repo-fork-sync.txtar +++ b/acceptance/testdata/repos/repo-fork-sync.txtar @@ -30,15 +30,13 @@ exec git push # Checkout the forked repo and ensure asset.txt is not present cd ../$SCRIPT_NAME-$RANDOM_STRING-fork exec git checkout main -exec ls -! stdout asset.txt +! exists asset.txt # Sync the forked repo with the original repo exec gh repo sync # Check that asset.txt now exists in the fork -exec ls -stdout asset.txt +exists asset.txt -- asset.txt -- Hello, world! From 6c3ad5011b7acb076a039582d52eb6f4f72b16fb Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Fri, 18 Oct 2024 08:47:15 -0700 Subject: [PATCH 14/16] Remove unnecessary flags from repo-delete testscript --- acceptance/testdata/repos/repo-delete.txtar | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance/testdata/repos/repo-delete.txtar b/acceptance/testdata/repos/repo-delete.txtar index 2e0bbc62a..b82388068 100644 --- a/acceptance/testdata/repos/repo-delete.txtar +++ b/acceptance/testdata/repos/repo-delete.txtar @@ -9,5 +9,5 @@ stdout $SCRIPT_NAME-$RANDOM_STRING exec gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING # Ensure that the repo was deleted -! exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING --json name --jq '.name' +! exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING stderr 'Could not resolve to a Repository with the name' From 3f4a2aea2f95d41b633ade524dc800424a884228 Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Fri, 18 Oct 2024 09:22:58 -0700 Subject: [PATCH 15/16] Rename acceptance test directory from repos to repo --- acceptance/acceptance_test.go | 4 ++-- .../testdata/{repos => repo}/repo-archive-unarchive.txtar | 0 acceptance/testdata/{repos => repo}/repo-clone.txtar | 0 acceptance/testdata/{repos => repo}/repo-create-view.txtar | 0 acceptance/testdata/{repos => repo}/repo-delete.txtar | 0 acceptance/testdata/{repos => repo}/repo-deploy-key.txtar | 0 acceptance/testdata/{repos => repo}/repo-edit.txtar | 0 acceptance/testdata/{repos => repo}/repo-fork-sync.txtar | 0 acceptance/testdata/{repos => repo}/repo-list-rename.txtar | 0 acceptance/testdata/{repos => repo}/repo-set-default.txtar | 0 10 files changed, 2 insertions(+), 2 deletions(-) rename acceptance/testdata/{repos => repo}/repo-archive-unarchive.txtar (100%) rename acceptance/testdata/{repos => repo}/repo-clone.txtar (100%) rename acceptance/testdata/{repos => repo}/repo-create-view.txtar (100%) rename acceptance/testdata/{repos => repo}/repo-delete.txtar (100%) rename acceptance/testdata/{repos => repo}/repo-deploy-key.txtar (100%) rename acceptance/testdata/{repos => repo}/repo-edit.txtar (100%) rename acceptance/testdata/{repos => repo}/repo-fork-sync.txtar (100%) rename acceptance/testdata/{repos => repo}/repo-list-rename.txtar (100%) rename acceptance/testdata/{repos => repo}/repo-set-default.txtar (100%) diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index 366d88cf4..18757cda7 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -72,12 +72,12 @@ func TestReleases(t *testing.T) { testscript.Run(t, testScriptParamsFor(tsEnv, "release")) } -func TestRepos(t *testing.T) { +func TestRepo(t *testing.T) { var tsEnv testScriptEnv if err := tsEnv.fromEnv(); err != nil { t.Fatal(err) } - testscript.Run(t, testScriptParamsFor(tsEnv, "repos")) + testscript.Run(t, testScriptParamsFor(tsEnv, "repo")) } func testScriptParamsFor(tsEnv testScriptEnv, command string) testscript.Params { diff --git a/acceptance/testdata/repos/repo-archive-unarchive.txtar b/acceptance/testdata/repo/repo-archive-unarchive.txtar similarity index 100% rename from acceptance/testdata/repos/repo-archive-unarchive.txtar rename to acceptance/testdata/repo/repo-archive-unarchive.txtar diff --git a/acceptance/testdata/repos/repo-clone.txtar b/acceptance/testdata/repo/repo-clone.txtar similarity index 100% rename from acceptance/testdata/repos/repo-clone.txtar rename to acceptance/testdata/repo/repo-clone.txtar diff --git a/acceptance/testdata/repos/repo-create-view.txtar b/acceptance/testdata/repo/repo-create-view.txtar similarity index 100% rename from acceptance/testdata/repos/repo-create-view.txtar rename to acceptance/testdata/repo/repo-create-view.txtar diff --git a/acceptance/testdata/repos/repo-delete.txtar b/acceptance/testdata/repo/repo-delete.txtar similarity index 100% rename from acceptance/testdata/repos/repo-delete.txtar rename to acceptance/testdata/repo/repo-delete.txtar diff --git a/acceptance/testdata/repos/repo-deploy-key.txtar b/acceptance/testdata/repo/repo-deploy-key.txtar similarity index 100% rename from acceptance/testdata/repos/repo-deploy-key.txtar rename to acceptance/testdata/repo/repo-deploy-key.txtar diff --git a/acceptance/testdata/repos/repo-edit.txtar b/acceptance/testdata/repo/repo-edit.txtar similarity index 100% rename from acceptance/testdata/repos/repo-edit.txtar rename to acceptance/testdata/repo/repo-edit.txtar diff --git a/acceptance/testdata/repos/repo-fork-sync.txtar b/acceptance/testdata/repo/repo-fork-sync.txtar similarity index 100% rename from acceptance/testdata/repos/repo-fork-sync.txtar rename to acceptance/testdata/repo/repo-fork-sync.txtar diff --git a/acceptance/testdata/repos/repo-list-rename.txtar b/acceptance/testdata/repo/repo-list-rename.txtar similarity index 100% rename from acceptance/testdata/repos/repo-list-rename.txtar rename to acceptance/testdata/repo/repo-list-rename.txtar diff --git a/acceptance/testdata/repos/repo-set-default.txtar b/acceptance/testdata/repo/repo-set-default.txtar similarity index 100% rename from acceptance/testdata/repos/repo-set-default.txtar rename to acceptance/testdata/repo/repo-set-default.txtar From ba324d85ebc3c210c445b93c86daa72f1ee57191 Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Fri, 18 Oct 2024 09:34:13 -0700 Subject: [PATCH 16/16] Wrap true in '' in repo-fork-sync --- acceptance/testdata/repo/repo-fork-sync.txtar | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance/testdata/repo/repo-fork-sync.txtar b/acceptance/testdata/repo/repo-fork-sync.txtar index 5b2362ffe..6ed7b94e1 100644 --- a/acceptance/testdata/repo/repo-fork-sync.txtar +++ b/acceptance/testdata/repo/repo-fork-sync.txtar @@ -18,7 +18,7 @@ sleep 5 # Check that the repo was forked exec gh repo view $ORG/$SCRIPT_NAME-$RANDOM_STRING-fork --json='isFork' --jq='.isFork' -stdout true +stdout 'true' # Modify original repo cd $SCRIPT_NAME-$RANDOM_STRING