This commit is contained in:
parent
2ca93e9a9f
commit
631f442798
@ -74,19 +74,19 @@ func TestExecute_GmailAttachment_OutPath_JSON(t *testing.T) {
|
||||
run := func() (string, map[string]any) {
|
||||
out := captureStdout(t, func() {
|
||||
_ = captureStderr(t, func() {
|
||||
if err := Execute([]string{
|
||||
if execErr := Execute([]string{
|
||||
"--output", "json",
|
||||
"--account", "a@b.com",
|
||||
"gmail", "attachment", "m1", "a1",
|
||||
"--out", outPath,
|
||||
}); err != nil {
|
||||
t.Fatalf("Execute: %v", err)
|
||||
}); execErr != nil {
|
||||
t.Fatalf("Execute: %v", execErr)
|
||||
}
|
||||
})
|
||||
})
|
||||
var parsed map[string]any
|
||||
if err := json.Unmarshal([]byte(out), &parsed); err != nil {
|
||||
t.Fatalf("json parse: %v\nout=%q", err, out)
|
||||
if unmarshalErr := json.Unmarshal([]byte(out), &parsed); unmarshalErr != nil {
|
||||
t.Fatalf("json parse: %v\nout=%q", unmarshalErr, out)
|
||||
}
|
||||
return out, parsed
|
||||
}
|
||||
|
||||
@ -45,13 +45,13 @@ func newGmailAttachmentCmd(flags *rootFlags) *cobra.Command {
|
||||
}
|
||||
|
||||
if strings.TrimSpace(outPath) == "" {
|
||||
dir, err := config.EnsureGmailAttachmentsDir()
|
||||
if err != nil {
|
||||
return err
|
||||
dir, dirErr := config.EnsureGmailAttachmentsDir()
|
||||
if dirErr != nil {
|
||||
return dirErr
|
||||
}
|
||||
path, cached, err := downloadAttachment(cmd, svc, messageID, info, dir)
|
||||
if err != nil {
|
||||
return err
|
||||
path, cached, dlErr := downloadAttachment(cmd, svc, messageID, info, dir)
|
||||
if dlErr != nil {
|
||||
return dlErr
|
||||
}
|
||||
if outfmt.IsJSON(cmd.Context()) {
|
||||
return outfmt.WriteJSON(os.Stdout, map[string]any{"path": path, "cached": cached})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user