Skip to content

Commit fed5df9

Browse files
Add repo autolink acceptance test
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d5151527-3286-43fd-a420-38f496a076fa
1 parent d30ab8d commit fed5df9

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Create a repository to hold the autolink references
2+
exec gh repo create $ORG/$SCRIPT_NAME-$RANDOM_STRING --add-readme --private
3+
4+
# Defer repo cleanup
5+
defer gh repo delete --yes $ORG/$SCRIPT_NAME-$RANDOM_STRING
6+
7+
# List the autolinks. There should be none
8+
exec gh repo autolink list --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=keyPrefix
9+
! stdout keyPrefix
10+
11+
# Create an alphanumeric autolink
12+
exec gh repo autolink create --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING TICKET- 'https://example.com/TICKET?query=<num>'
13+
14+
# Ensure the autolink was created
15+
exec gh repo autolink list --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=keyPrefix --jq='.[].keyPrefix'
16+
stdout 'TICKET-'
17+
18+
# Get the autolink id
19+
exec gh repo autolink list --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=keyPrefix,id --jq='.[] | select(.keyPrefix == "TICKET-") | .id'
20+
stdout2env AUTOLINK_ID
21+
22+
# View the autolink and ensure the url template round tripped
23+
exec gh repo autolink view --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING $AUTOLINK_ID --json=urlTemplate --jq='.urlTemplate'
24+
stdout 'https://example\.com/TICKET\?query=<num>'
25+
26+
# Delete the autolink
27+
exec gh repo autolink delete --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING $AUTOLINK_ID --yes
28+
29+
# Ensure the autolink was deleted
30+
exec gh repo autolink list --repo $ORG/$SCRIPT_NAME-$RANDOM_STRING --json=id --jq='.[].id'
31+
! stdout $AUTOLINK_ID

0 commit comments

Comments
 (0)