version promote --help says the current file is rewritten (closes #153)
check / check (push) Waiting to run
check / check (push) Waiting to run
The help text for `secret version promote` and a comment in PromoteVersion said promote updates a "current symlink". `current` is a plain file holding the version name, and promote rewrites it; the README already says so. A new test runs `secret version promote --help` and checks the output does not mention a symlink and does name the current file. Model: opus-5-5
This commit was merged in pull request #180.
This commit is contained in:
@@ -64,7 +64,7 @@ func VersionCommands(cli *Instance) *cobra.Command {
|
|||||||
promoteCmd := &cobra.Command{
|
promoteCmd := &cobra.Command{
|
||||||
Use: "promote <secret-name> <version>",
|
Use: "promote <secret-name> <version>",
|
||||||
Short: "Promote a specific version to current",
|
Short: "Promote a specific version to current",
|
||||||
Long: "Updates the current symlink to point to the specified " +
|
Long: "Rewrites the secret's current file to name the specified " +
|
||||||
"version. The versions' own times are left unchanged; secret " +
|
"version. The versions' own times are left unchanged; secret " +
|
||||||
"list then gives the time of the promote as the secret's last " +
|
"list then gives the time of the promote as the secret's last " +
|
||||||
"update.",
|
"update.",
|
||||||
@@ -293,7 +293,7 @@ func (cli *Instance) PromoteVersion(
|
|||||||
version, vault.ErrVersionNotFound, secretName)
|
version, vault.ErrVersionNotFound, secretName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the current symlink using the proper function
|
// Rewrite the secret's current file to name the version
|
||||||
err = secret.SetCurrentVersion(cli.fs, secretDir, version)
|
err = secret.SetCurrentVersion(cli.fs, secretDir, version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to update current version: %w", err)
|
return fmt.Errorf("failed to update current version: %w", err)
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
// - TestListVersionsNonExistentSecret: Tests error handling for missing secrets
|
// - TestListVersionsNonExistentSecret: Tests error handling for missing secrets
|
||||||
// - TestPromoteVersionCommand: Tests `secret version promote` command
|
// - TestPromoteVersionCommand: Tests `secret version promote` command
|
||||||
// - TestPromoteNonExistentVersion: Tests error handling for invalid promotion
|
// - TestPromoteNonExistentVersion: Tests error handling for invalid promotion
|
||||||
|
// - TestPromoteHelpSaysCurrentFileIsRewritten: Tests `secret version promote
|
||||||
|
// --help` text
|
||||||
// - TestGetSecretWithVersion: Tests `secret get --version` flag functionality
|
// - TestGetSecretWithVersion: Tests `secret get --version` flag functionality
|
||||||
// - TestGetSecretWritesBinaryValue: Tests `secret get` output of binary values
|
// - TestGetSecretWritesBinaryValue: Tests `secret get` output of binary values
|
||||||
// - TestGetSecretReturnsWriteError: Tests `secret get` when stdout fails
|
// - TestGetSecretReturnsWriteError: Tests `secret get` when stdout fails
|
||||||
@@ -270,6 +272,23 @@ func TestPromoteNonExistentVersion(t *testing.T) {
|
|||||||
require.ErrorIs(t, err, vault.ErrVersionNotFound)
|
require.ErrorIs(t, err, vault.ErrVersionNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestPromoteHelpSaysCurrentFileIsRewritten is a regression test for
|
||||||
|
// https://git.eeqj.de/sneak/secret/issues/153: `secret version promote
|
||||||
|
// --help` said it updates a symlink, but promote rewrites the secret's
|
||||||
|
// `current` file, which is a plain file.
|
||||||
|
//
|
||||||
|
//nolint:paralleltest // executes the CLI in-process and sets the environment
|
||||||
|
func TestPromoteHelpSaysCurrentFileIsRewritten(t *testing.T) {
|
||||||
|
env := map[string]string{secret.EnvStateDir: t.TempDir()}
|
||||||
|
|
||||||
|
output, err := ExecuteCommandInProcess(
|
||||||
|
[]string{"version", "promote", "--help"}, "", env)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
assert.NotContains(t, output, "symlink")
|
||||||
|
assert.Contains(t, output, "current file")
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetSecretWithVersion(t *testing.T) {
|
func TestGetSecretWithVersion(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user