@@ -30,49 +30,63 @@ import (
3030func TestV3ProductCatalogSmoke (t * testing.T ) {
3131 c := newV3Client (t )
3232
33- meterKey := uniqueKey ("sanity_meter" )
34- eventType := uniqueKey ("sanity_event" )
35- featureKey := uniqueKey ("sanity_feature" )
33+ eventTypes := []string {
34+ uniqueKey ("sanity_event" ),
35+ uniqueKey ("sanity_event" ),
36+ }
3637
37- var (
38- meterID string
39- featureID string
40- planID string
41- addonID string
42- planAddonID string
43- phaseKey string
44- )
38+ meterKeys := []string {
39+ uniqueKey ("sanity_meter" ),
40+ uniqueKey ("sanity_meter" ),
41+ }
42+
43+ meters := make ([]apiv3.Meter , 0 , len (meterKeys ))
4544
46- t . Run ( "Should create a meter" , func ( t * testing. T ) {
45+ for i := range meterKeys {
4746 valueProperty := "$.value"
47+
4848 status , m , problem := c .CreateMeter (apiv3.CreateMeterRequest {
49- Key : meterKey ,
50- Name : "Test Meter " + meterKey ,
49+ Key : meterKeys [ i ] ,
50+ Name : "Test Meter " + meterKeys [ i ] ,
5151 Aggregation : apiv3 .MeterAggregationSum ,
52- EventType : eventType ,
52+ EventType : eventTypes [ i ] ,
5353 ValueProperty : & valueProperty ,
5454 })
5555 require .Equal (t , http .StatusCreated , status , "problem: %+v" , problem )
5656 require .NotNil (t , m )
5757 require .NotEmpty (t , m .Id )
58- meterID = m .Id
59- })
6058
61- t .Run ("Should create a feature bound to the meter" , func (t * testing.T ) {
62- require .NotEmpty (t , meterID )
59+ meters = append (meters , * m )
60+ }
61+
62+ featureKeys := []string {
63+ uniqueKey ("sanity_feature" ),
64+ uniqueKey ("sanity_feature" ),
65+ }
6366
67+ features := make ([]apiv3.Feature , 0 , len (featureKeys ))
68+
69+ for i := range featureKeys {
6470 status , f , problem := c .CreateFeature (apiv3.CreateFeatureRequest {
65- Key : featureKey ,
66- Name : "Test Feature " + featureKey ,
71+ Key : featureKeys [ i ] ,
72+ Name : "Test Feature " + featureKeys [ i ] ,
6773 Meter : & apiv3.FeatureMeterReference {
68- Id : meterID ,
74+ Id : meters [ i ]. Id ,
6975 },
7076 })
7177 require .Equal (t , http .StatusCreated , status , "problem: %+v" , problem )
7278 require .NotNil (t , f )
7379 require .NotEmpty (t , f .Id )
74- featureID = f .Id
75- })
80+
81+ features = append (features , * f )
82+ }
83+
84+ var (
85+ planID string
86+ addonID string
87+ planAddonID string
88+ phaseKey string
89+ )
7690
7791 t .Run ("Should create a draft plan with a single flat rate card" , func (t * testing.T ) {
7892 body := validPlanRequest ("sanity_plan" )
@@ -89,21 +103,15 @@ func TestV3ProductCatalogSmoke(t *testing.T) {
89103 })
90104
91105 t .Run ("Should update the plan to carry flat + usage + graduated rate cards" , func (t * testing.T ) {
92- t .Skip ("Skip this test as it does not use rate cards with features properly" )
93-
94- require .NotEmpty (t , planID )
95- require .NotEmpty (t , phaseKey )
96- require .NotEmpty (t , featureID )
97-
98106 // Three different rate card shapes on one phase. The flat fee is
99107 // in_advance, both usage-based ones are in_arrears (unit/graduated
100108 // prices cannot be in_advance). Only the unit one carries a feature
101109 // reference here — the graduated case follows the addon mixed
102110 // round-trip pattern (no feature) to keep this iteration close to
103111 // known-good shapes.
104112 flat := validFlatRateCard ("sanity_flat" )
105- usage := validUsageRateCard ( "sanity_usage" , featureID )
106- graduated := validGraduatedRateCard ("sanity_graduated" )
113+ usage := validUnitRateCard ( features [ 0 ] )
114+ graduated := validGraduatedRateCard (features [ 1 ] )
107115
108116 update := apiv3.UpsertPlanRequest {
109117 Name : "Sanity Plan" ,
@@ -129,16 +137,14 @@ func TestV3ProductCatalogSmoke(t *testing.T) {
129137 }
130138 require .NotNil (t , usageRC , "usage rate card missing after update" )
131139 require .NotNil (t , usageRC .Feature , "usage rate card lost its feature binding after update" )
132- assert .Equal (t , featureID , usageRC .Feature .Id )
140+ assert .Equal (t , usage . Feature . Id , usageRC .Feature .Id )
133141 })
134142
135143 // Track the three valid rate cards across the invalid-loop subtests so
136144 // "remove defective" PUTs can rebuild the phase from the same baseline.
137145 var validRateCards []apiv3.BillingRateCard
138146
139147 t .Run ("Should add a defective rate card and surface validation_errors" , func (t * testing.T ) {
140- t .Skip ("Skip this test as it does not use rate cards with features properly" )
141-
142148 require .NotEmpty (t , planID )
143149 require .NotEmpty (t , phaseKey )
144150
@@ -190,8 +196,6 @@ func TestV3ProductCatalogSmoke(t *testing.T) {
190196 })
191197
192198 t .Run ("Should remove the defective rate card and clear validation_errors" , func (t * testing.T ) {
193- t .Skip ("Skip this test as it does not use rate cards with features properly" )
194-
195199 require .NotEmpty (t , planID )
196200 require .NotEmpty (t , phaseKey )
197201 require .NotEmpty (t , validRateCards )
0 commit comments