# Setup environment variables used for testscript
env REPO=${SCRIPT_NAME}-${RANDOM_STRING}
env VAR_NAME=TESTSCRIPTS

# 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 repository variable does not exist
exec gh variable list
! stdout $VAR_NAME

# Create a repository variable
exec gh variable set $VAR_NAME --body 'just a repo variable'

# Verify new repository variable exists
exec gh variable list
stdout $VAR_NAME

# Verify repository variable can be retrieved
exec gh variable get $VAR_NAME
stdout 'just a repo variable'
