Fix Postfixadmin alias updating (don't leave commas at the start/end).
[mailshears.git] / test / test_prune.rb
index a0e69417e0f633cf1eeba599ff4d31fd39ec5a36..35c1a5c6941d391c008807df8d79fc392ff76183 100644 (file)
@@ -32,18 +32,18 @@ class TestPrune < MailshearsTest
 
     # Now make sure the database has what we expect.
 
-    arm = AgendavPrune.new(cfg)
-    actual = arm.list_users()
+    apr = AgendavPrune.new(cfg)
+    actual = apr.list_users()
     expected = [User.new('adam@example.net')]
     assert_equal(expected, actual)
 
-    drm = DavicalPrune.new(cfg)
-    actual = drm.list_users()
+    dpr = DavicalPrune.new(cfg)
+    actual = dpr.list_users()
     expected = [User.new('alice@example.com')]
     assert_equal(expected, actual)
 
-    pfarm = PostfixadminPrune.new(cfg)
-    actual = pfarm.list_users()
+    pfapr = PostfixadminPrune.new(cfg)
+    actual = pfapr.list_users()
     expected = [User.new('alice@example.com'),
                 User.new('bob@example.com'),
                 User.new('adam@example.net'),
@@ -51,25 +51,29 @@ class TestPrune < MailshearsTest
                 User.new('carol@example.net')]
     assert_equal(expected, actual)
 
-    actual = pfarm.list_domains()
+    actual = pfapr.list_domains()
     expected = [Domain.new('example.com'), Domain.new('example.net')]
     assert_equal(expected, actual)
 
-    actual = pfarm.list_aliases()
-    expected = [{'address' => 'alice@example.com',
-                    'goto' => 'alice@example.com'},
-                {'address' => 'bob@example.com',
-                    'goto' => 'bob@example.com'},
-                {'address' => 'adam@example.net',
-                    'goto' => 'adam@example.net'},
+    actual = pfapr.list_aliases()
+    expected = [{'address' => 'adam@example.net',
+                 'goto' => 'adam@example.net'},
+                {'address' => 'alice@example.com',
+                 'goto' => 'alice@example.com,' +
+                           'adam@example.net,' +
+                           'bob@example.com,' +
+                           'carol@example.net'},
                 {'address' => 'beth@example.net',
-                    'goto' => 'beth@example.net'},
+                 'goto' => 'beth@example.net'},
+                {'address' => 'bob@example.com',
+                 'goto' => 'bob@example.com'},
                 {'address' => 'carol@example.net',
-                    'goto' => 'carol@example.net'}]
-    assert_equal(expected, actual)
+                 'goto' => 'carol@example.net'}]
+    expected.each { |e| assert(actual.include?(e)) } # can't sort dicts
+    actual.each { |a| assert(expected.include?(a)) } # can't sort dicts
 
-    rrm = RoundcubePrune.new(cfg)
-    actual = rrm.list_users()
+    rpr = RoundcubePrune.new(cfg)
+    actual = rpr.list_users()
     expected = [User.new('alice@example.com'), User.new('adam@example.net')]
     assert_equal(expected, actual)