Skip to content

Commit d938402

Browse files
committed
[DE-1091] Fix tests after sdk update
1 parent e89145f commit d938402

File tree

5 files changed

+27
-37
lines changed

5 files changed

+27
-37
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
env:
1010
TEST_API_KEY: ${{secrets.TEST_API_KEY}}
1111
TEST_API_PASSWORD: ${{secrets.TEST_API_PASSWORD}}
12-
TEST_DOMAIN: ${{vars.TEST_DOMAIN}}
1312
TEST_SUBDOMAIN: ${{vars.TEST_SUBDOMAIN}}
1413

1514
jobs:

test/component_allocations_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,7 @@ func (s *ComponentAlocationSuite) TestComponentAllocations() {
4444
},
4545
},
4646
},
47-
UnitPrice: models.ToPointer(models.OnOffComponentUnitPriceContainer.FromString("100")),
48-
Prices: []models.Price{
49-
{
50-
StartingQuantity: models.PriceStartingQuantityContainer.FromNumber(1),
51-
UnitPrice: models.PriceUnitPriceContainer.FromPrecision(1),
52-
},
53-
},
47+
UnitPrice: models.OnOffComponentUnitPriceContainer.FromString("100"),
5448
},
5549
},
5650
)

test/site_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (s *SiteSuite) TestReadSite() {
8181
name: "unauthorized",
8282
client: s.unauthorizedClient,
8383
assert: func(t *testing.T, resp models.ApiResponse[models.SiteResponse], err error) {
84-
s.Equal(err.Error(), "ApiError occured: HTTP Response Not OK. Status code: 401. Response: 'HTTP Basic: Access denied.\n'.")
84+
s.Equal(err.Error(), "ApiError occurred: HTTP Response Not OK. Status code: 401. Response: 'HTTP Basic: Access denied.\n'.")
8585
actualErr, ok := err.(https.ApiError)
8686
s.Equal(http.StatusUnauthorized, actualErr.StatusCode)
8787
s.True(ok)

test/subscription_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,38 +99,38 @@ func (s *SubscriptionSuite) TestSubscriptionCreate() {
9999
ctx,
100100
advancedbilling.ListSubscriptionComponentsForSiteInput{
101101
SubscriptionIds: []int{*createdSubscription.Id},
102-
Include: models.ToPointer(models.ListSubscriptionComponentsInclude_SUBSCRIPTION),
102+
Include: models.ToPointer(models.ListSubscriptionComponentsInclude_SUBSCRIPTION),
103103
Filter: models.ToPointer(models.ListSubscriptionComponentsForSiteFilter{
104-
Subscription: models.ToPointer(models.SubscriptionFilter{
105-
DateField: models.ToPointer(models.SubscriptionListDateField_UPDATEDAT),
106-
StartDate: timePtr(time.Now().AddDate(-1, 0, 0)),
107-
}),
104+
Subscription: models.ToPointer(models.SubscriptionFilter{
105+
DateField: models.ToPointer(models.SubscriptionListDateField_UPDATEDAT),
106+
StartDate: timePtr(time.Now().AddDate(-1, 0, 0)),
107+
}),
108108
}),
109109
},
110110
)
111111

112112
s.NoError(err)
113-
s.Equal(http.StatusOK, listComponentsFilteredResp1.Response.StatusCode)
114-
s.Len(listComponentsFilteredResp1.Data.SubscriptionsComponents, 1)
115-
s.Equal(component.Id, listComponentsFilteredResp1.Data.SubscriptionsComponents[0].ComponentId)
113+
s.Equal(http.StatusOK, listComponentsFilteredResp1.Response.StatusCode)
114+
s.Len(listComponentsFilteredResp1.Data.SubscriptionsComponents, 1)
115+
s.Equal(component.Id, listComponentsFilteredResp1.Data.SubscriptionsComponents[0].ComponentId)
116116

117-
listComponentsFilteredResp2, err := s.client.SubscriptionComponentsController().ListSubscriptionComponentsForSite(
117+
listComponentsFilteredResp2, err := s.client.SubscriptionComponentsController().ListSubscriptionComponentsForSite(
118118
ctx,
119119
advancedbilling.ListSubscriptionComponentsForSiteInput{
120120
SubscriptionIds: []int{*createdSubscription.Id},
121-
Include: models.ToPointer(models.ListSubscriptionComponentsInclude_SUBSCRIPTION),
121+
Include: models.ToPointer(models.ListSubscriptionComponentsInclude_SUBSCRIPTION),
122122
Filter: models.ToPointer(models.ListSubscriptionComponentsForSiteFilter{
123-
Subscription: models.ToPointer(models.SubscriptionFilter{
124-
DateField: models.ToPointer(models.SubscriptionListDateField_UPDATEDAT),
125-
EndDate: timePtr(time.Now().AddDate(-1, 0, 0)),
126-
}),
123+
Subscription: models.ToPointer(models.SubscriptionFilter{
124+
DateField: models.ToPointer(models.SubscriptionListDateField_UPDATEDAT),
125+
EndDate: timePtr(time.Now().AddDate(-1, 0, 0)),
126+
}),
127127
}),
128128
},
129129
)
130130

131131
s.NoError(err)
132-
s.Equal(http.StatusOK, listComponentsFilteredResp2.Response.StatusCode)
133-
s.Len(listComponentsFilteredResp2.Data.SubscriptionsComponents, 0)
132+
s.Equal(http.StatusOK, listComponentsFilteredResp2.Response.StatusCode)
133+
s.Len(listComponentsFilteredResp2.Data.SubscriptionsComponents, 0)
134134
},
135135
},
136136
{
@@ -168,7 +168,7 @@ func (s *SubscriptionSuite) TestSubscriptionCreate() {
168168
},
169169
),
170170
assert: func(t *testing.T, ar models.ApiResponse[models.SubscriptionResponse], cs models.CreateSubscription, err error) {
171-
s.Equal("ApiError occured: HTTP Response Not OK. Status code: 401. Response: 'HTTP Basic: Access denied.\n'.",
171+
s.Equal("ApiError occurred: HTTP Response Not OK. Status code: 401. Response: 'HTTP Basic: Access denied.\n'.",
172172
err.Error())
173173

174174
actualErr, ok := err.(https.ApiError)

test/suite.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
type Config struct {
1818
APIKey string `env:"TEST_API_KEY,required"`
1919
Password string `env:"TEST_API_PASSWORD,required"`
20-
Domain string `env:"TEST_DOMAIN,required"`
2120
Subdomain string `env:"TEST_SUBDOMAIN,required"`
2221
}
2322

@@ -63,8 +62,7 @@ func (s *APISuite) SetupTest() {
6362
cfg.Password,
6463
),
6564
),
66-
advancedbilling.WithDomain(cfg.Domain),
67-
advancedbilling.WithSubdomain(cfg.Subdomain),
65+
advancedbilling.WithSite(cfg.Subdomain),
6866
)
6967

7068
configUnauthorized := advancedbilling.CreateConfiguration(
@@ -74,8 +72,7 @@ func (s *APISuite) SetupTest() {
7472
"abc",
7573
),
7674
),
77-
advancedbilling.WithDomain(cfg.Domain),
78-
advancedbilling.WithSubdomain(cfg.Subdomain),
75+
advancedbilling.WithSite(cfg.Subdomain),
7976
)
8077

8178
s.client = advancedbilling.NewClient(config)
@@ -153,11 +150,11 @@ func (s *APISuite) generateProduct(ctx context.Context, productFamilyID int) mod
153150
}
154151

155152
func (s *APISuite) generateCoupon(ctx context.Context, productFamilyID int) models.Coupon {
156-
coupon := &models.CreateOrUpdatePercentageCoupon{
157-
Name: s.fkr.RandomStringWithLength(20),
158-
Code: "100OFF" + s.fkr.RandomStringWithLength(30),
153+
coupon := &models.CouponPayload{
154+
Name: models.ToPointer(s.fkr.RandomStringWithLength(20)),
155+
Code: models.ToPointer("100OFF" + s.fkr.RandomStringWithLength(30)),
159156
Description: strPtr(s.fkr.RandomStringWithLength(20)),
160-
Percentage: models.CreateOrUpdatePercentageCouponPercentageContainer.FromString("50"),
157+
Percentage: models.ToPointer(models.CouponPayloadPercentageContainer.FromString("50")),
161158
AllowNegativeBalance: boolPtr(false),
162159
Recurring: boolPtr(false),
163160
EndDate: timePtr(time.Now().AddDate(1, 0, 0)),
@@ -167,8 +164,8 @@ func (s *APISuite) generateCoupon(ctx context.Context, productFamilyID int) mode
167164
ApplyOnCancelAtEndOfPeriod: boolPtr(true),
168165
}
169166

170-
resp, err := s.client.CouponsController().CreateCoupon(ctx, productFamilyID, &models.CreateOrUpdateCoupon{
171-
Coupon: models.ToPointer(models.CreateOrUpdateCouponCouponContainer.FromCreateOrUpdatePercentageCoupon(*coupon)),
167+
resp, err := s.client.CouponsController().CreateCoupon(ctx, productFamilyID, &models.CouponRequest{
168+
Coupon: models.ToPointer(*coupon),
172169
})
173170

174171
s.NoError(err)

0 commit comments

Comments
 (0)