check / check (push) Failing after 2s
REPO_POLICIES.md requires the module root sneak.berlin/go/<name>. go.mod, every import (rewritten with gofmt -r), the -X flags in script/build and the examples in the pkg READMEs now use the new path. go mod tidy lists go-humanize and fatih/color as direct requirements, since internal/cli imports them. This breaks anyone who fetched or imported git.eeqj.de/sneak/secret: they must switch to sneak.berlin/go/secret, which resolves to this repository. Model: opus-5-5
63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
package cli_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/spf13/cobra"
|
|
"sneak.berlin/go/secret/internal/cli"
|
|
"sneak.berlin/go/secret/internal/vault"
|
|
)
|
|
|
|
// TestMissingSecretOrVaultErrors checks that a command that finds no such
|
|
// secret or vault returns the vault package's error for it, as `secret get`
|
|
// does, and leaves the vaults unchanged. "default" is the current vault, and
|
|
// both vaults hold the secret "x".
|
|
func TestMissingSecretOrVaultErrors(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
before := snapshotStateDir(t, newTwoVaultFs(t))
|
|
|
|
tests := []struct {
|
|
command string
|
|
want error
|
|
run func(c *cli.Instance) error
|
|
}{
|
|
{
|
|
"rm --force nosuch", vault.ErrSecretNotFound,
|
|
func(c *cli.Instance) error {
|
|
return c.RemoveSecret(&cobra.Command{}, "nosuch", true)
|
|
},
|
|
},
|
|
{
|
|
"version rm --force nosuch", vault.ErrSecretNotFound,
|
|
func(c *cli.Instance) error {
|
|
return c.RemoveVersion(&cobra.Command{}, "nosuch", "20260101.001", true)
|
|
},
|
|
},
|
|
{
|
|
"mv --force work:nosuch default", vault.ErrSecretNotFound,
|
|
func(c *cli.Instance) error {
|
|
return c.MoveSecret(&cobra.Command{}, "work:nosuch", "default", true)
|
|
},
|
|
},
|
|
{
|
|
"decrypt nosuch", vault.ErrSecretNotFound,
|
|
func(c *cli.Instance) error { return c.Decrypt("nosuch", "", "") },
|
|
},
|
|
{
|
|
"vault rm --force nosuch", vault.ErrVaultNotFound,
|
|
func(c *cli.Instance) error {
|
|
return c.RemoveVault(&cobra.Command{}, "nosuch", true)
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.command, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
requireRejectedAndUnchanged(t, before, tt.want, tt.run)
|
|
})
|
|
}
|
|
}
|