From 0ed413a2a11e625da385f31502a55ba8533c42ac Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 14 Oct 2026 22:56:14 +0000 Subject: [PATCH] version promote --help says the current file is rewritten (closes #153) 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 --- internal/cli/version.go | 4 ++-- internal/cli/version_test.go | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/internal/cli/version.go b/internal/cli/version.go index ca862a4..a4b8a8c 100644 --- a/internal/cli/version.go +++ b/internal/cli/version.go @@ -64,7 +64,7 @@ func VersionCommands(cli *Instance) *cobra.Command { promoteCmd := &cobra.Command{ Use: "promote ", 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 " + "list then gives the time of the promote as the secret's last " + "update.", @@ -293,7 +293,7 @@ func (cli *Instance) PromoteVersion( 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) if err != nil { return fmt.Errorf("failed to update current version: %w", err) diff --git a/internal/cli/version_test.go b/internal/cli/version_test.go index 8904da6..f50d64b 100644 --- a/internal/cli/version_test.go +++ b/internal/cli/version_test.go @@ -6,6 +6,8 @@ // - TestListVersionsNonExistentSecret: Tests error handling for missing secrets // - TestPromoteVersionCommand: Tests `secret version promote` command // - TestPromoteNonExistentVersion: Tests error handling for invalid promotion +// - TestPromoteHelpSaysCurrentFileIsRewritten: Tests `secret version promote +// --help` text // - TestGetSecretWithVersion: Tests `secret get --version` flag functionality // - TestGetSecretWritesBinaryValue: Tests `secret get` output of binary values // - TestGetSecretReturnsWriteError: Tests `secret get` when stdout fails @@ -270,6 +272,23 @@ func TestPromoteNonExistentVersion(t *testing.T) { 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) { t.Parallel()