return users.map{ |u| User.new(u) }
end
+
+ # Count the number of rows in the "shares" table. Used only for
+ # testing.
+ #
+ # @return [Fixnum] the number of rows in the "shares" table.
+ #
+ def count_shares()
+ count = nil
+ connection = PG::Connection.new(@db_hash)
+
+ sql_query = 'SELECT count(*) FROM shares;'
+ begin
+ connection.query(sql_query) do |result|
+ count = result.getvalue(0,0).to_i()
+ end
+ ensure
+ # Make sure the connection gets closed even if the query explodes.
+ connection.close()
+ end
+
+ return count
+ end
+
end
'/carol%40example.net/',
'a:0:{}',
true);
+
+/* These two are missing a prefs entry to test the removal of "shares"
+ * entries in that situation.
+*/
+INSERT INTO shares (owner, calendar, "with", options, rw)
+ VALUES ('/caldav.php/stinky%40example.com/',
+ '/caldav.php/stinky%40example.com/calendar-default',
+ '/herp%40example.net/',
+ 'a:0:{}',
+ true);
+
+INSERT INTO shares (owner, calendar, "with", options, rw)
+ VALUES ('/caldav.php/goober%40example.com/',
+ '/caldav.php/goober%40example.com/calendar-default',
+ '/derp%40example.net/',
+ 'a:0:{}',
+ true);
expected = [User.new('booger@example.com')]
assert_equal(expected, actual)
+ # Only try to remove this guy from the agendav database, to ensure
+ # that "nonexistent" users have their shares removed.
+ arm.remove_user('stinky@example.com')
+ expected = 2
+ actual = arm.count_shares()
+ assert_equal(expected, actual)
+
drm = DavicalRm.new(cfg)
actual = drm.list_users()
expected = [User.new('alice@example.com'), User.new('booger@example.com')]