Add comprehensive tests for hackathon service functionality
- Implemented tests for creating, retrieving, updating, and deleting hackathons. - Added validation tests for hackathon creation and updates. - Included tests for hackathon events and timelines, ensuring proper handling of edge cases. - Created tests for hackathon submissions, including validation and submission status updates. - Organized tests into a dedicated module for better structure and maintainability.
This commit is contained in:
@@ -43,6 +43,14 @@ pub enum ResourceEnum {
|
||||
TeamMembers,
|
||||
/// Team invitations table for pending invitations
|
||||
TeamInvitations,
|
||||
/// Hackathons table for hackathon events
|
||||
Hackathons,
|
||||
/// Hackathon events table for hackathon-specific events
|
||||
HackathonEvents,
|
||||
/// Hackathon timeline table for schedule milestones
|
||||
HackathonTimeline,
|
||||
/// Hackathon submissions table for project submissions
|
||||
HackathonSubmissions,
|
||||
}
|
||||
|
||||
impl fmt::Display for ResourceEnum {
|
||||
@@ -64,6 +72,10 @@ impl fmt::Display for ResourceEnum {
|
||||
ResourceEnum::Teams => "app_teams",
|
||||
ResourceEnum::TeamMembers => "app_team_members",
|
||||
ResourceEnum::TeamInvitations => "app_team_invitations",
|
||||
ResourceEnum::Hackathons => "app_hackathons",
|
||||
ResourceEnum::HackathonEvents => "app_hackathon_events",
|
||||
ResourceEnum::HackathonTimeline => "app_hackathon_timeline",
|
||||
ResourceEnum::HackathonSubmissions => "app_hackathon_submissions",
|
||||
};
|
||||
write!(f, "{}", table_name)
|
||||
}
|
||||
@@ -100,6 +112,10 @@ impl ResourceEnum {
|
||||
ResourceEnum::Teams => "app_teams",
|
||||
ResourceEnum::TeamMembers => "app_team_members",
|
||||
ResourceEnum::TeamInvitations => "app_team_invitations",
|
||||
ResourceEnum::Hackathons => "app_hackathons",
|
||||
ResourceEnum::HackathonEvents => "app_hackathon_events",
|
||||
ResourceEnum::HackathonTimeline => "app_hackathon_timeline",
|
||||
ResourceEnum::HackathonSubmissions => "app_hackathon_submissions",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +141,20 @@ impl ResourceEnum {
|
||||
)
|
||||
}
|
||||
|
||||
/// Check if this resource is hackathon-related.
|
||||
///
|
||||
/// # Returns
|
||||
/// true if the resource is part of the hackathon system, false otherwise
|
||||
pub fn is_hackathon(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
ResourceEnum::Hackathons
|
||||
| ResourceEnum::HackathonEvents
|
||||
| ResourceEnum::HackathonTimeline
|
||||
| ResourceEnum::HackathonSubmissions
|
||||
)
|
||||
}
|
||||
|
||||
/// Check if this resource is user-related.
|
||||
///
|
||||
/// # Returns
|
||||
|
||||
Reference in New Issue
Block a user