@@ -512,3 +512,36 @@ func assertInvalidParameterRule(t *testing.T, problem *v3Problem, rule string) {
512512 }
513513 assert .Failf (t , "invalid parameter rule not found" , "expected %q, got %v" , rule , rules )
514514}
515+
516+ // findRateCardByKey looks up a rate card by key across all phases of a plan.
517+ // Fails the test if no match is found.
518+ func findRateCardByKey (t * testing.T , plan * apiv3.BillingPlan , key string ) * apiv3.BillingRateCard {
519+ t .Helper ()
520+
521+ for i := range plan .Phases {
522+ for j := range plan .Phases [i ].RateCards {
523+ rc := & plan .Phases [i ].RateCards [j ]
524+ if rc .Key == key {
525+ return rc
526+ }
527+ }
528+ }
529+
530+ require .FailNow (t , "rate card not found" , "key=%s" , key )
531+ return nil
532+ }
533+
534+ // assertUnitPriceAmount asserts the rate card's price discriminates as "unit"
535+ // and carries the given amount. Used to verify the synthesized unit price that
536+ // replaces v1 dynamic and package prices on the v3 read path.
537+ func assertUnitPriceAmount (t * testing.T , rc * apiv3.BillingRateCard , want string ) {
538+ t .Helper ()
539+
540+ disc , err := rc .Price .Discriminator ()
541+ require .NoError (t , err )
542+ require .Equal (t , "unit" , disc , "expected synthesized unit price" )
543+
544+ unit , err := rc .Price .AsBillingPriceUnit ()
545+ require .NoError (t , err )
546+ assert .Equal (t , want , unit .Amount )
547+ }
0 commit comments