Address PR feedback

This commit is contained in:
Tyler McGoffin 2024-10-23 13:56:09 -07:00
parent 59aedc4e89
commit 2b480daf7a
4 changed files with 6 additions and 34 deletions

View file

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

View file

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

View file

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

View file

@ -1,3 +1,3 @@
# Check the authentication status
exec gh auth status --hostname $GH_HOST
stdout $GH_HOST
stdout '✓ Logged in to '