feat: sync deployed v1.0.0-rc.38-custom.67
This commit is contained in:
1 parent
d09216bbde
commit
8e6ed0317b
154 files changed
+39540
-20509
No files matched your search
@@ -0,0 +1,22 @@
|
||||
package billingexpr
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestImageGenerationPriceSizesAndQuantity(t *testing.T) {
|
||||
expression := `(param("size") != nil && (param("size") == "4k" || (param("size") matches "^[0-9]+x[0-9]+$" && min(float(split(param("size"), "x")[0]), float(split(param("size"), "x")[1])) > 2048)) ? tier("4k", fixed(0.12)) : param("size") != nil && (param("size") == "2k" || (param("size") matches "^[0-9]+x[0-9]+$" && min(float(split(param("size"), "x")[0]), float(split(param("size"), "x")[1])) > 1024)) ? tier("2k", fixed(0.08)) : tier("1k", fixed(0.06))) * image_count`
|
||||
for _, tc := range []struct {
|
||||
body, tier string
|
||||
price float64
|
||||
}{{`{}`, "1k", 0.06}, {`{"size":"auto"}`, "1k", 0.06}, {`{"size":"1024x1536"}`, "1k", 0.06}, {`{"size":"2048x1152"}`, "2k", 0.08}, {`{"size":"3840x2160"}`, "4k", 0.12}, {`{"size":"2k"}`, "2k", 0.08}} {
|
||||
for _, n := range []int{1, 2, 3} {
|
||||
cost, trace, err := RunExprWithRequest(expression, TokenParams{P: 10000, C: 5000}, RequestInput{Body: []byte(tc.body), ImageCount: &n})
|
||||
require.NoError(t, err)
|
||||
require.InDelta(t, tc.price*float64(n)*1000000, cost, 0.01)
|
||||
require.Equal(t, tc.tier, trace.MatchedTier)
|
||||
require.Equal(t, BillingUnitRequest, trace.BillingUnit)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user