Mercurial > projects > managesieve
comparison example_test.go @ 4:f9bb517e9447
Return warning messages from the CHECKSCRIPT and PUTSCRIPT commands
author | Guido Berhoerster <guido+managesieve@berhoerster.name> |
---|---|
date | Tue, 27 Oct 2020 17:47:14 +0100 |
parents | 6369453d47a3 |
children |
comparison
equal
deleted
inserted
replaced
3:8413916df2be | 4:f9bb517e9447 |
---|---|
67 if err := c.Authenticate(auth); err != nil { | 67 if err := c.Authenticate(auth); err != nil { |
68 log.Fatalf("failed to authenticate user %s: %s", username, err) | 68 log.Fatalf("failed to authenticate user %s: %s", username, err) |
69 } | 69 } |
70 | 70 |
71 // Check the validity of the script. | 71 // Check the validity of the script. |
72 if err = c.CheckScript(script); err != nil { | 72 if warnings, err := c.CheckScript(script); err != nil { |
73 log.Fatalf("script %q is not valid: %s", scriptName, err) | 73 log.Fatalf("script %q is not valid: %s", scriptName, err) |
74 } else if warnings != "" { | |
75 log.Printf("warning: %s", warnings) | |
74 } | 76 } |
75 | 77 |
76 // Check whether ther is sufficient space for uploading the script. | 78 // Check whether ther is sufficient space for uploading the script. |
77 if ok, err := c.HaveSpace(scriptName, int64(len(script))); err != nil { | 79 if ok, err := c.HaveSpace(scriptName, int64(len(script))); err != nil { |
78 log.Fatalf("failed to determine whether there is enough space: %s", | 80 log.Fatalf("failed to determine whether there is enough space: %s", |
80 } else if !ok { | 82 } else if !ok { |
81 log.Fatalf("not enough space to upload script %q", scriptName) | 83 log.Fatalf("not enough space to upload script %q", scriptName) |
82 } | 84 } |
83 | 85 |
84 // Upload the script. | 86 // Upload the script. |
85 if err = c.PutScript(scriptName, script); err != nil { | 87 if warnings, err := c.PutScript(scriptName, script); err != nil { |
86 log.Fatalf("failed to upload script %q: %s", scriptName, err) | 88 log.Fatalf("failed to upload script %q: %s", scriptName, err) |
89 } else if warnings != "" { | |
90 log.Printf("warning: %s", warnings) | |
87 } | 91 } |
88 | 92 |
89 // Activate the uploaded script | 93 // Activate the uploaded script |
90 if err = c.ActivateScript(scriptName); err != nil { | 94 if err = c.ActivateScript(scriptName); err != nil { |
91 log.Fatalf("failed to set script %q active: %s", scriptName, | 95 log.Fatalf("failed to set script %q active: %s", scriptName, |