secret ls: align docs, completion, and tests; fix formatting

- Use SecretListReport for --format completion and correct help text
- Update manpage placeholders and ordering per xref rules
- Add and adjust e2e tests; verify CreatedAt contains 'ago'
- gofmt formatting fixes

Signed-off-by: shiavm006 <shivammittal42006@gmail.com>
This commit is contained in:
shiavm006
2025-10-02 17:33:38 +05:30
parent 116e4588c4
commit 00309d3955
3 changed files with 35 additions and 11 deletions

View File

@@ -325,6 +325,35 @@ var _ = Describe("Podman secret", func() {
Expect(list.OutputToStringArray()).To(HaveLen(2), list.OutputToString())
})
It("podman secret ls with valid format fields Driver/CreatedAt", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).ToNot(HaveOccurred())
podmanTest.PodmanExitCleanly("secret", "create", "fmt", secretFilePath)
// .Driver should be available on SecretListReport
list := podmanTest.PodmanExitCleanly("secret", "ls", "--format", "{{.Driver}}")
Expect(list.OutputToString()).ToNot(BeEmpty())
// .CreatedAt should be available and human-readable (e.g., "X ago")
list = podmanTest.PodmanExitCleanly("secret", "ls", "--format", "{{.CreatedAt}}")
Expect(list.OutputToString()).To(ContainSubstring("ago"))
})
It("podman secret ls with invalid Spec.* format should error", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
Expect(err).ToNot(HaveOccurred())
podmanTest.PodmanExitCleanly("secret", "create", "fmt2", secretFilePath)
bad := podmanTest.Podman([]string{"secret", "ls", "--format", "{{.Spec.Name}}"})
bad.WaitWithDefaultTimeout()
Expect(bad).To(Not(ExitCleanly()))
Expect(bad.ErrorToString()).To(ContainSubstring("can't evaluate field Spec"))
})
It("podman secret rm", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)