]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Test] Improve folding tests
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 2 Apr 2018 13:58:16 +0000 (14:58 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 2 Apr 2018 13:58:16 +0000 (14:58 +0100)
test/lua/unit/folding.lua

index b4904f797ecec56d5298b000f326e6eabdb3aebf..3721a05f009704aed8fffe13e30a200d807ba698 100644 (file)
@@ -48,13 +48,19 @@ context("Headers folding unit test", function()
      "Returnpath_BL2,HFILTER_FROM_BOUNCE,R_PARTS_DIFFER,\r\n\tR_IP_PBL,R_ONE_RCPT,R_googleredir,R_TO_SEEMS_AUTO,R_SPF_NEUTRAL,R_PRIORITY_3,\r\n\tRBL_SPAMHAUS_PBL,HFILTER_MID_NOT_FQDN,MISSING_CTE,R_HAS_URL,RBL_SPAMHAUS_CSS,\r\n\tRBL_SPAMHAUS_XBL,BAYES_SPAM,RECEIVED_RBL10"
     },
   }
+  local function escape_spaces(str)
+    str = string.gsub(str, '[\r\n]+', '<NL>')
+    str = string.gsub(str, '[ ]', '<SP>')
+    str = string.gsub(str, '[\t]', '<TB>')
 
+    return str
+  end
   for i,c in ipairs(cases) do
     test("Headers folding: " .. i, function()
       local fv = util.fold_header(c[1][1], c[1][2], 'crlf', ';')
       assert_not_nil(fv)
       assert_equal(fv, c[2], string.format("'%s' doesn't match with '%s'",
-              c[2], fv))
+              escape_spaces(c[2]), escape_spaces(fv)))
     end)
   end
 end)