feat: new free plan (#5604)

This commit is contained in:
DarkSky
2024-01-17 07:20:18 +00:00
parent 3f87d04481
commit 8f80bdb7af
8 changed files with 104 additions and 15 deletions

View File

@@ -48,6 +48,7 @@ test('should be able to set quota', async t => {
const q1 = await quota.getUserQuota(u1.id);
t.truthy(q1, 'should have quota');
t.is(q1?.feature.name, QuotaType.FreePlanV1, 'should be free plan');
t.is(q1?.feature.version, 2, 'should be version 2');
await quota.switchUserQuota(u1.id, QuotaType.ProPlanV1);
@@ -63,8 +64,8 @@ test('should be able to check storage quota', async t => {
const u1 = await auth.signUp('DarkSky', 'darksky@example.org', '123456');
const q1 = await storageQuota.getUserQuota(u1.id);
t.is(q1?.blobLimit, Quotas[0].configs.blobLimit, 'should be free plan');
t.is(q1?.storageQuota, Quotas[0].configs.storageQuota, 'should be free plan');
t.is(q1?.blobLimit, Quotas[3].configs.blobLimit, 'should be free plan');
t.is(q1?.storageQuota, Quotas[3].configs.storageQuota, 'should be free plan');
await quota.switchUserQuota(u1.id, QuotaType.ProPlanV1);
const q2 = await storageQuota.getUserQuota(u1.id);
@@ -77,8 +78,8 @@ test('should be able revert quota', async t => {
const u1 = await auth.signUp('DarkSky', 'darksky@example.org', '123456');
const q1 = await storageQuota.getUserQuota(u1.id);
t.is(q1?.blobLimit, Quotas[0].configs.blobLimit, 'should be free plan');
t.is(q1?.storageQuota, Quotas[0].configs.storageQuota, 'should be free plan');
t.is(q1?.blobLimit, Quotas[3].configs.blobLimit, 'should be free plan');
t.is(q1?.storageQuota, Quotas[3].configs.storageQuota, 'should be free plan');
await quota.switchUserQuota(u1.id, QuotaType.ProPlanV1);
const q2 = await storageQuota.getUserQuota(u1.id);
@@ -87,7 +88,7 @@ test('should be able revert quota', async t => {
await quota.switchUserQuota(u1.id, QuotaType.FreePlanV1);
const q3 = await storageQuota.getUserQuota(u1.id);
t.is(q3?.blobLimit, Quotas[0].configs.blobLimit, 'should be free plan');
t.is(q3?.blobLimit, Quotas[3].configs.blobLimit, 'should be free plan');
const quotas = await quota.getUserQuotas(u1.id);
t.is(quotas.length, 3, 'should have 3 quotas');

View File

@@ -182,7 +182,7 @@ test('should reject blob exceeded limit', async t => {
const buffer2 = Buffer.from(Array.from({ length: OneMB + 1 }, () => 0));
await t.notThrowsAsync(setBlob(app, u1.token.token, workspace1.id, buffer2));
const buffer3 = Buffer.from(Array.from({ length: 10 * OneMB + 1 }, () => 0));
const buffer3 = Buffer.from(Array.from({ length: 100 * OneMB + 1 }, () => 0));
await t.throwsAsync(setBlob(app, u1.token.token, workspace1.id, buffer3));
});