gateway_request_pricing_test.go 545 B

1234567891011121314151617181920
  1. //go:build unit
  2. package service
  3. import (
  4. "context"
  5. "testing"
  6. "github.com/stretchr/testify/require"
  7. )
  8. func TestWithGatewayTokenRequestPricingMarksOnlyExplicitTokenRequests(t *testing.T) {
  9. ctx, pricingAt := WithGatewayTokenRequestPricing(context.Background())
  10. got, ok := gatewayTokenRequestPricingAtFromContext(ctx)
  11. require.True(t, ok)
  12. require.Equal(t, pricingAt, got)
  13. require.Equal(t, pricingAt, GatewayTokenRequestPricingAtFromContext(ctx))
  14. require.True(t, GatewayTokenRequestPricingAtFromContext(context.Background()).IsZero())
  15. }