diff 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
line wrap: on
line diff
--- a/example_test.go	Mon Oct 26 15:24:43 2020 +0100
+++ b/example_test.go	Tue Oct 27 17:47:14 2020 +0100
@@ -69,8 +69,10 @@
 	}
 
 	// Check the validity of the script.
-	if err = c.CheckScript(script); err != nil {
+	if warnings, err := c.CheckScript(script); err != nil {
 		log.Fatalf("script %q is not valid: %s", scriptName, err)
+	} else if warnings != "" {
+		log.Printf("warning: %s", warnings)
 	}
 
 	// Check whether ther is sufficient space for uploading the script.
@@ -82,8 +84,10 @@
 	}
 
 	// Upload the script.
-	if err = c.PutScript(scriptName, script); err != nil {
+	if warnings, err := c.PutScript(scriptName, script); err != nil {
 		log.Fatalf("failed to upload script %q: %s", scriptName, err)
+	} else if warnings != "" {
+		log.Printf("warning: %s", warnings)
 	}
 
 	// Activate the uploaded script