Add acceptance tests for release commands

This commit is contained in:
bagtoad 2024-10-16 11:03:50 -06:00 committed by William Martin
parent d2559f007f
commit a009933a16
5 changed files with 79 additions and 2 deletions

View file

@ -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 != "" {

View file

@ -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

16
acceptance/testdata/release/list.txtar vendored Normal file
View 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 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'

View file

@ -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!

16
acceptance/testdata/release/view.txtar vendored Normal file
View 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 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'