Add IsRecommendable method and corresponding tests for Tender entity
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
- Implemented the IsRecommendable method in the Tender entity to determine if a tender should be included in AI recommendations based on its status and deadline. - Added unit tests for the IsRecommendable method to cover various scenarios, ensuring accurate recommendation logic. - Updated the Recommend method in the tender service to utilize the new IsRecommendable method for improved clarity and functionality. This update enhances the recommendation logic for tenders, ensuring only appropriate tenders are considered for AI recommendations based on their status and deadlines.
This commit is contained in:
@@ -72,3 +72,52 @@ func TestResolvedEstimatedValueAndCurrencyPrefersTopLevel(t *testing.T) {
|
||||
t.Fatalf("expected USD, got %q", currency)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTenderIsRecommendable(t *testing.T) {
|
||||
now := int64(1_700_000_000)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
tender Tender
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "active with future deadline",
|
||||
tender: Tender{Status: TenderStatusActive, TenderDeadline: now + 3600},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "active with past deadline",
|
||||
tender: Tender{Status: TenderStatusActive, TenderDeadline: now - 3600},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "active with deadline at now",
|
||||
tender: Tender{Status: TenderStatusActive, TenderDeadline: now},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "active without deadline",
|
||||
tender: Tender{Status: TenderStatusActive, TenderDeadline: 0},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "expired status with future deadline",
|
||||
tender: Tender{Status: TenderStatusExpired, TenderDeadline: now + 3600},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "awarded with future deadline",
|
||||
tender: Tender{Status: TenderStatusAwarded, TenderDeadline: now + 3600},
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := tt.tender.IsRecommendable(now); got != tt.want {
|
||||
t.Fatalf("IsRecommendable() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user