feat: complete remaining Go backend modules
This commit is contained in:
1 parent
cea2751dc5
commit
aef5a97165
145 files changed
+18376
-199
No files matched your search
@@ -76,3 +76,31 @@ func TestCatalogExemptsDisabledMockAndSuperAdmin(t *testing.T) {
|
||||
t.Fatalf("quote = %#v, %v", quote, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCatalogMatchesLegacyVariantKeyAsEffectiveConditions(t *testing.T) {
|
||||
rules := []PriceRule{
|
||||
{ID: "720", Provider: "seedance", Capability: "video.generate", ReqKey: "seedance-2", VariantKey: "resolution=720p", Unit: UnitVideoSecond, StandardUnitPriceFen: 99, MarkupMultiplier: 1.2, Enabled: true},
|
||||
{ID: "1080", Provider: "seedance", Capability: "video.generate", ReqKey: "seedance-2", VariantKey: "resolution=1080p", Unit: UnitVideoSecond, StandardUnitPriceFen: 248, MarkupMultiplier: 1.2, Enabled: true},
|
||||
}
|
||||
quote, err := (Catalog{Rules: rules}).Quote(QuoteInput{
|
||||
Provider: "seedance", Capability: "video.generate", ReqKey: "seedance-2",
|
||||
Parameters: Parameters{"resolution": " 720P ", "duration": 5.0},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if quote.PriceRuleID != "720" || quote.VariantKey != "resolution=720p" || quote.AmountFen != 594 {
|
||||
t.Fatalf("quote = %#v", quote)
|
||||
}
|
||||
if quote.Conditions["resolution"] != "720p" {
|
||||
t.Fatalf("effective conditions = %#v", quote.Conditions)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCatalogExplicitConditionsOverrideLegacyVariantKey(t *testing.T) {
|
||||
rule := PriceRule{ID: "override", Provider: "seedance", Capability: "video.generate", VariantKey: "resolution=720p", Conditions: Conditions{"resolution": "1080p"}, Unit: UnitRequest, StandardUnitPriceFen: 1, MarkupMultiplier: 1, Enabled: true}
|
||||
quote, err := (Catalog{Rules: []PriceRule{rule}}).Quote(QuoteInput{Provider: "seedance", Capability: "video.generate", Parameters: Parameters{"resolution": "1080P"}})
|
||||
if err != nil || quote == nil || quote.Conditions["resolution"] != "1080p" {
|
||||
t.Fatalf("quote = %#v, err = %v", quote, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user