Skip to content

Commit 5b35b72

Browse files
committed
fix(api): evaluate cloud namespace limits before enterprise' one
1 parent bd6cdac commit 5b35b72

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

api/services/device.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,6 @@ func (s *service) UpdateDeviceStatus(ctx context.Context, tenant string, uid mod
322322
}
323323

324324
switch {
325-
case envs.IsCommunity(), envs.IsEnterprise():
326-
if namespace.HasMaxDevices() && namespace.HasMaxDevicesReached() {
327-
return NewErrDeviceMaxDevicesReached(namespace.MaxDevices)
328-
}
329325
case envs.IsCloud():
330326
if namespace.Billing.IsActive() {
331327
if err := s.BillingReport(s.client, namespace.TenantID, ReportDeviceAccept); err != nil {
@@ -362,6 +358,10 @@ func (s *service) UpdateDeviceStatus(ctx context.Context, tenant string, uid mod
362358
return ErrDeviceLimit
363359
}
364360
}
361+
case envs.IsCommunity(), envs.IsEnterprise():
362+
if namespace.HasMaxDevices() && namespace.HasMaxDevicesReached() {
363+
return NewErrDeviceMaxDevicesReached(namespace.MaxDevices)
364+
}
365365
}
366366

367367
if err := s.store.DeviceUpdateStatus(ctx, uid, status); err != nil {

api/services/device_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,7 +2330,7 @@ func TestUpdateDeviceStatus_community_and_enterprise(t *testing.T) {
23302330
envMock.
23312331
On("Get", "SHELLHUB_CLOUD").
23322332
Return("false").
2333-
Once()
2333+
Twice()
23342334
envMock.
23352335
On("Get", "SHELLHUB_ENTERPRISE").
23362336
Return("false").
@@ -2398,7 +2398,7 @@ func TestUpdateDeviceStatus_community_and_enterprise(t *testing.T) {
23982398
envMock.
23992399
On("Get", "SHELLHUB_CLOUD").
24002400
Return("false").
2401-
Once()
2401+
Twice()
24022402
envMock.
24032403
On("Get", "SHELLHUB_ENTERPRISE").
24042404
Return("false").
@@ -2469,7 +2469,7 @@ func TestUpdateDeviceStatus_community_and_enterprise(t *testing.T) {
24692469
Once()
24702470
envMock.
24712471
On("Get", "SHELLHUB_CLOUD").
2472-
Return("false").Once()
2472+
Return("false").Twice()
24732473
envMock.
24742474
On("Get", "SHELLHUB_ENTERPRISE").
24752475
Return("false").Once()

0 commit comments

Comments
 (0)