Mercurial > projects > managesieve
diff managesieve_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 | b790df0733d4 |
line wrap: on
line diff
--- a/managesieve_test.go Mon Oct 26 15:24:43 2020 +0100 +++ b/managesieve_test.go Tue Oct 27 17:47:14 2020 +0100 @@ -118,6 +118,7 @@ redirect "lists@groups.example.com"; } ` +var expectedWarnings = "line 8: server redirect action limit is 2, this redirect might be ignored" // basic functionality var basicServer string = `"IMPlemENTATION" "Example1 ManageSieved v001" @@ -137,9 +138,9 @@ "MAXREdIRECTS" "5" "VERSION" "1.0" OK -OK (WARNINGS) "line 8: server redirect action limit is 2, this redirect might be ignored" +OK (WARNINGS) "` + expectedWarnings + `" OK -OK (WARNINGS) "line 8: server redirect action limit is 2, this redirect might be ignored" +OK (WARNINGS) "` + expectedWarnings + `" OK "default" ACTIVE OK @@ -217,8 +218,11 @@ t.Fatalf("plain authentication failed: %s", err) } - if err = c.CheckScript(validScript); err != nil { + if warnings, err := c.CheckScript(validScript); err != nil { t.Fatalf("CHECKSCRIPT failed: %s", err) + } else if warnings != expectedWarnings { + t.Fatalf("CHECKSCRIPT expected: %s, got %s", warnings, + expectedWarnings) } if ok, err := c.HaveSpace("default", int64(len(validScript))); err != nil { @@ -227,8 +231,11 @@ t.Fatal("HaveSpace unexpectedly returned false") } - if err = c.PutScript("default", validScript); err != nil { + if warnings, err := c.PutScript("default", validScript); err != nil { t.Fatalf("PUTSCRIPT failed: %s", err) + } else if warnings != expectedWarnings { + t.Fatalf("PUTSCRIPT expected: %s, got %s", warnings, + expectedWarnings) } if err = c.ActivateScript("default"); err != nil { @@ -523,7 +530,7 @@ } // invalid script name - err = c.PutScript("def\u2028ault", validScript) + _, err = c.PutScript("def\u2028ault", validScript) if err == nil { t.Fatalf("expected error but succeeded") } @@ -533,7 +540,7 @@ } // EOF during upload - err = c.PutScript("default", validScript) + _, err = c.PutScript("default", validScript) if err == nil { t.Fatalf("expected error but succeeded") } @@ -738,7 +745,7 @@ err, err) } - err = c.CheckScript(validScript) + _, err = c.CheckScript(validScript) if err == nil { t.Fatalf("expected error but succeeded") }