Add acceptance tests for gh variable
This commit is contained in:
parent
e335113706
commit
b4be8cbf9d
3 changed files with 82 additions and 0 deletions
20
acceptance/testdata/variable/variable-org.txtar
vendored
Normal file
20
acceptance/testdata/variable/variable-org.txtar
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Prepare organization variable, GitHub Actions uppercases names
|
||||
env2upper ORG_VARIABLE_NAME=$RANDOM_STRING
|
||||
|
||||
# Confirm organization variable does not exist, will fail admin:org scope missing
|
||||
! exec gh variable get $ORG_VARIABLE_NAME --org $ORG
|
||||
stderr 'variable .+ was not found'
|
||||
|
||||
# Create an organization variable
|
||||
exec gh variable set $ORG_VARIABLE_NAME --org $ORG --body 'just an org variable'
|
||||
|
||||
# Defer organization variable cleanup
|
||||
defer gh variable delete $ORG_VARIABLE_NAME --org $ORG
|
||||
|
||||
# Confirm organization variable exists
|
||||
exec gh variable list --org $ORG
|
||||
stdout $ORG_VARIABLE_NAME
|
||||
|
||||
# Verify repository environment variable can be retrieved
|
||||
exec gh variable get $ORG_VARIABLE_NAME --org $ORG
|
||||
stdout 'just an org variable'
|
||||
33
acceptance/testdata/variable/variable-repo-env.txtar
vendored
Normal file
33
acceptance/testdata/variable/variable-repo-env.txtar
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Force GitHub CLI to treat testscript as TTY
|
||||
env GH_FORCE_TTY=80
|
||||
env REPO=$SCRIPT_NAME-$RANDOM_STRING
|
||||
|
||||
# Create a repository where the variable will be registered
|
||||
exec gh repo create $ORG/$REPO --add-readme --private
|
||||
|
||||
# Defer repo cleanup
|
||||
defer gh repo delete --yes $ORG/$REPO
|
||||
|
||||
# Clone the repo
|
||||
exec gh repo clone $ORG/$REPO
|
||||
cd $REPO
|
||||
|
||||
# Create a repository environment, will fail if organization does not have environment support
|
||||
exec gh api /repos/$ORG/$REPO/environments/testscripts -X PUT --jq '.name'
|
||||
stdout 'testscripts'
|
||||
|
||||
# Verify no repository environment variables exist
|
||||
exec gh variable list --env testscripts
|
||||
stderr 'no variables found'
|
||||
|
||||
# Create a repository environment variable
|
||||
exec gh variable set TESTSCRIPTS_ENV --env testscripts --body 'just a repo env variable'
|
||||
stdout 'Created variable TESTSCRIPTS_ENV for'
|
||||
|
||||
# Verify new repository environment variable exists
|
||||
exec gh variable list --env testscripts
|
||||
stdout 'TESTSCRIPTS_ENV\s+just a repo env variable\s+less than a minute ago'
|
||||
|
||||
# Verify repository environment variable can be retrieved
|
||||
exec gh variable get TESTSCRIPTS_ENV --env testscripts
|
||||
stdout 'just a repo env variable'
|
||||
29
acceptance/testdata/variable/variable-repo.txtar
vendored
Normal file
29
acceptance/testdata/variable/variable-repo.txtar
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Setup environment variables to force TTY
|
||||
env GH_FORCE_TTY=80
|
||||
env REPO=$SCRIPT_NAME-$RANDOM_STRING
|
||||
|
||||
# Create a repository where the variable will be registered
|
||||
exec gh repo create $ORG/$REPO --add-readme --private
|
||||
|
||||
# Defer repo cleanup
|
||||
defer gh repo delete --yes $ORG/$REPO
|
||||
|
||||
# Clone the repo
|
||||
exec gh repo clone $ORG/$REPO
|
||||
cd $REPO
|
||||
|
||||
# Verify no repository variables exist
|
||||
exec gh variable list
|
||||
stderr 'no variables found'
|
||||
|
||||
# Create a repository variable
|
||||
exec gh variable set TESTSCRIPTS --body 'just a repo variable'
|
||||
stdout 'Created variable TESTSCRIPTS for'
|
||||
|
||||
# Verify new repository variable exists
|
||||
exec gh variable list
|
||||
stdout 'TESTSCRIPTS\s+just a repo variable\s+less than a minute ago'
|
||||
|
||||
# Verify repository variable can be retrieved
|
||||
exec gh variable get TESTSCRIPTS
|
||||
stdout 'just a repo variable'
|
||||
Loading…
Add table
Add a link
Reference in a new issue