From 2b480daf7abba51332ef1493a6d19120bc4c9ddd Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Wed, 23 Oct 2024 13:56:09 -0700 Subject: [PATCH] Address PR feedback --- acceptance/acceptance_test.go | 19 ------------------- .../testdata/auth/auth-login-logout.txtar | 10 ++-------- acceptance/testdata/auth/auth-setup-git.txtar | 9 +++------ acceptance/testdata/auth/auth-status.txtar | 2 +- 4 files changed, 6 insertions(+), 34 deletions(-) diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index ace985af6..dd5b8b0d1 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -203,17 +203,6 @@ func sharedCmds(tsEnv testScriptEnv) map[string]func(ts *testscript.TestScript, ts.Setenv(env[:i], strings.ToUpper(env[i+1:])) } }, - // Creates a formatted string using standard fmt.Sprintf syntax - // and sets it as an environment variable of the given name. - "formattedStringToEnv": func(ts *testscript.TestScript, neg bool, args []string) { - if neg { - ts.Fatalf("unsupported: ! formattedStringToEnv") - } - if len(args) < 3 { - ts.Fatalf("usage: formattedStringToEnv name string args...") - } - ts.Setenv(args[0], fmt.Sprintf(args[1], toAnySlice(args[2:])...)) - }, "replace": func(ts *testscript.TestScript, neg bool, args []string) { if neg { ts.Fatalf("unsupported: ! replace") @@ -281,14 +270,6 @@ func sharedCmds(tsEnv testScriptEnv) map[string]func(ts *testscript.TestScript, } } -func toAnySlice(strings []string) []any { - anys := make([]any, len(strings)) - for i, s := range strings { - anys[i] = s - } - return anys -} - var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func randomString(n int) string { diff --git a/acceptance/testdata/auth/auth-login-logout.txtar b/acceptance/testdata/auth/auth-login-logout.txtar index 3933ce1da..fb25f9eb5 100644 --- a/acceptance/testdata/auth/auth-login-logout.txtar +++ b/acceptance/testdata/auth/auth-login-logout.txtar @@ -1,19 +1,13 @@ -# We aren't logged in at the moment, but GH_HOST will override the -# need to login. We are going to clear GH_HOST first to ensure no +# We aren't logged in at the moment, but GH_TOKEN will override the +# need to login. We are going to clear GH_TOKEN first to ensure no # overrides are happening # Copy $GH_TOKEN to a new env var env LOGIN_TOKEN=$GH_TOKEN -exec echo $LOGIN_TOKEN -stdout $GH_TOKEN # Remove GH_TOKEN env var so we don't fall back to it env GH_TOKEN='' -# Ensure the token was deleted -exec echo $GH_TOKEN -! stdout '.' - # Login to the host by feeding the token to stdin exec echo $LOGIN_TOKEN stdin stdout diff --git a/acceptance/testdata/auth/auth-setup-git.txtar b/acceptance/testdata/auth/auth-setup-git.txtar index 84794ae8f..e3be28cd5 100644 --- a/acceptance/testdata/auth/auth-setup-git.txtar +++ b/acceptance/testdata/auth/auth-setup-git.txtar @@ -1,13 +1,10 @@ -# Setup the credential key name string -formattedStringToEnv CREDENTIAL_HELPER_KEY 'credential.https://%s.helper' $GH_HOST - # Check that the credential helper is unset for the host. This command is # expected to fail before gh auth setup-git is run. -! exec git config --get $CREDENTIAL_HELPER_KEY +! exec git config --get credential.https://${GH_HOST}.helper # Run the setup-git command exec gh auth setup-git # Check that the credential helper is set to gh -exec git config --get $CREDENTIAL_HELPER_KEY -stdout gh +exec git config --get credential.https://${GH_HOST}.helper +stdout '^.*gh auth git-credential$' diff --git a/acceptance/testdata/auth/auth-status.txtar b/acceptance/testdata/auth/auth-status.txtar index da3011d1a..2afee1eb6 100644 --- a/acceptance/testdata/auth/auth-status.txtar +++ b/acceptance/testdata/auth/auth-status.txtar @@ -1,3 +1,3 @@ # Check the authentication status exec gh auth status --hostname $GH_HOST -stdout $GH_HOST \ No newline at end of file +stdout '✓ Logged in to ' \ No newline at end of file