Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/services/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func (s *service) UpdateDeviceStatus(ctx context.Context, tenant string, uid mod
isRemoved := false

switch {
case envs.IsCloud():
case envs.IsCloud() && envs.HasBilling():
if namespace.Billing.IsActive() {
if err := s.BillingReport(s.client, namespace.TenantID, ReportDeviceAccept); err != nil {
return NewErrBillingReportNamespaceDelete(err)
Expand Down Expand Up @@ -370,7 +370,7 @@ func (s *service) UpdateDeviceStatus(ctx context.Context, tenant string, uid mod
return ErrDeviceLimit
}
}
case envs.IsCommunity(), envs.IsEnterprise():
default:
if namespace.HasMaxDevices() && namespace.HasMaxDevicesReached() {
return NewErrDeviceMaxDevicesReached(namespace.MaxDevices)
}
Expand Down
135 changes: 68 additions & 67 deletions api/services/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,7 @@ func TestUpdateDeviceStatus_community_and_enterprise(t *testing.T) {
envMock.
On("Get", "SHELLHUB_CLOUD").
Return("false").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
Expand Down Expand Up @@ -2398,7 +2398,7 @@ func TestUpdateDeviceStatus_community_and_enterprise(t *testing.T) {
envMock.
On("Get", "SHELLHUB_CLOUD").
Return("false").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
Expand Down Expand Up @@ -2469,7 +2469,7 @@ func TestUpdateDeviceStatus_community_and_enterprise(t *testing.T) {
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
Return("false").Twice()
Return("false").Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").Once()
Expand Down Expand Up @@ -2703,12 +2703,13 @@ func TestUpdateDeviceStatus_cloud_subscription_active(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").Once()
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
clientMock.
On("BillingReport", "00000000-0000-0000-0000-000000000000", "device_accept").
Return(0, errors.New("error", "", 0)).
Expand Down Expand Up @@ -2777,12 +2778,12 @@ func TestUpdateDeviceStatus_cloud_subscription_active(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
clientMock.
On("BillingReport", "00000000-0000-0000-0000-000000000000", "device_accept").
Expand Down Expand Up @@ -2852,12 +2853,12 @@ func TestUpdateDeviceStatus_cloud_subscription_active(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
clientMock.
On("BillingReport", "00000000-0000-0000-0000-000000000000", "device_accept").
Expand Down Expand Up @@ -2931,12 +2932,12 @@ func TestUpdateDeviceStatus_cloud_subscription_active(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
clientMock.
On("BillingReport", "00000000-0000-0000-0000-000000000000", "device_accept").
Expand Down Expand Up @@ -3168,12 +3169,12 @@ func TestUpdateDeviceStatus_cloud_subscription_inactive(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
storeMock.
On("DeviceRemovedGet", ctx, "00000000-0000-0000-0000-000000000000", models.UID("uid")).
Expand Down Expand Up @@ -3240,12 +3241,12 @@ func TestUpdateDeviceStatus_cloud_subscription_inactive(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
storeMock.
On("DeviceRemovedGet", ctx, "00000000-0000-0000-0000-000000000000", models.UID("uid")).
Expand Down Expand Up @@ -3321,12 +3322,12 @@ func TestUpdateDeviceStatus_cloud_subscription_inactive(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
storeMock.
On("DeviceRemovedGet", ctx, "00000000-0000-0000-0000-000000000000", models.UID("uid")).
Expand Down Expand Up @@ -3397,12 +3398,12 @@ func TestUpdateDeviceStatus_cloud_subscription_inactive(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
storeMock.
On("DeviceRemovedGet", ctx, "00000000-0000-0000-0000-000000000000", models.UID("uid")).
Expand Down Expand Up @@ -3477,12 +3478,12 @@ func TestUpdateDeviceStatus_cloud_subscription_inactive(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
storeMock.
On("DeviceRemovedGet", ctx, "00000000-0000-0000-0000-000000000000", models.UID("uid")).
Expand Down Expand Up @@ -3563,12 +3564,12 @@ func TestUpdateDeviceStatus_cloud_subscription_inactive(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
storeMock.
On("DeviceRemovedGet", ctx, "00000000-0000-0000-0000-000000000000", models.UID("uid")).
Expand Down Expand Up @@ -3653,12 +3654,12 @@ func TestUpdateDeviceStatus_cloud_subscription_inactive(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
storeMock.
On("DeviceRemovedGet", ctx, "00000000-0000-0000-0000-000000000000", models.UID("uid")).
Expand Down Expand Up @@ -3751,12 +3752,12 @@ func TestUpdateDeviceStatus_cloud_subscription_inactive(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
storeMock.
On("DeviceRemovedGet", ctx, "00000000-0000-0000-0000-000000000000", models.UID("uid")).
Expand Down Expand Up @@ -3827,12 +3828,12 @@ func TestUpdateDeviceStatus_cloud_subscription_inactive(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
storeMock.
On("DeviceRemovedGet", ctx, "00000000-0000-0000-0000-000000000000", models.UID("uid")).
Expand Down Expand Up @@ -3906,12 +3907,12 @@ func TestUpdateDeviceStatus_cloud_subscription_inactive(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
storeMock.
On("DeviceRemovedGet", ctx, "00000000-0000-0000-0000-000000000000", models.UID("uid")).
Expand Down Expand Up @@ -3992,12 +3993,12 @@ func TestUpdateDeviceStatus_cloud_subscription_inactive(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
storeMock.
On("DeviceRemovedGet", ctx, "00000000-0000-0000-0000-000000000000", models.UID("uid")).
Expand Down Expand Up @@ -4082,12 +4083,12 @@ func TestUpdateDeviceStatus_cloud_subscription_inactive(t *testing.T) {
Return(nil, store.ErrNoDocuments).
Once()
envMock.
On("Get", "SHELLHUB_CLOUD").
On("Get", "SHELLHUB_BILLING").
Return("true").
Twice()
Once()
envMock.
On("Get", "SHELLHUB_ENTERPRISE").
Return("false").
On("Get", "SHELLHUB_CLOUD").
Return("true").
Once()
storeMock.
On("DeviceRemovedGet", ctx, "00000000-0000-0000-0000-000000000000", models.UID("uid")).
Expand Down
Loading