#!/usr/bin/env python3
"""
测试 clear_all 方法
"""
from fastchatrooms.chatroom import ChatRoom


def test_clear_all():
    """测试清空所有数据库文件"""
    # 创建聊天室
    chatroom = ChatRoom('Test Room')
    
    # 添加用户
    chatroom.add('123', 'Test User')
    
    # 发送消息
    for i in range(5):
        chatroom.send('123', f'Message {i}')
    
    # 检查历史消息数量
    before_count = chatroom.history_count()
    print(f'Before clear_all: {before_count} messages')
    assert before_count > 0, "There should be messages before clear_all"
    
    # 清空所有数据库文件
    chatroom.clear_all()
    
    # 检查历史消息数量
    after_count = chatroom.history_count()
    print(f'After clear_all: {after_count} messages')
    assert after_count == 0, "There should be no messages after clear_all"
    
    print('Test passed!')


if __name__ == '__main__':
    test_clear_all()
