Skip to content

Commit 8ca4d87

Browse files
committed
chore: fix
1 parent fdd762d commit 8ca4d87

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

packages/cubejs-backend-shared/src/env.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function convertTimeStrToSeconds(
3333
throw new InvalidConfiguration(envName, input, description);
3434
}
3535

36-
export function convertByteSizeToNumber(
36+
export function convertSizeToBytes(
3737
input: string,
3838
envName: string,
3939
description: string = 'Must be a number in bytes or size string (1kb, 1mb, 1gb).',
@@ -175,7 +175,7 @@ const variables: Record<string, (...args: any) => any> = {
175175
serverKeepAliveTimeout: () => get('CUBEJS_SERVER_KEEP_ALIVE_TIMEOUT')
176176
.asInt(),
177177
maxRequestSize: () => {
178-
const value = convertByteSizeToNumber(process.env.CUBEJS_MAX_REQUEST_SIZE || '50mb', 'CUBEJS_MAX_REQUEST_SIZE');
178+
const value = convertSizeToBytes(process.env.CUBEJS_MAX_REQUEST_SIZE || '50mb', 'CUBEJS_MAX_REQUEST_SIZE');
179179

180180
const minBytes = 100 * 1024; // 100kb
181181
const maxBytes = 64 * 1024 * 1024; // 64mb

packages/cubejs-backend-shared/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export {
33
assertDataSource,
44
keyByDataSource,
55
isDockerImage,
6-
convertByteSizeToNumber,
6+
convertSizeToBytes,
77
} from './env';
88
export * from './enums';
99
export * from './package';

packages/cubejs-backend-shared/test/env.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getEnv, convertTimeStrToSeconds, convertByteSizeToNumber } from '../src/env';
1+
import { getEnv, convertTimeStrToSeconds, convertSizeToBytes } from '../src/env';
22

33
test('convertTimeStrToMs', () => {
44
expect(convertTimeStrToSeconds('1', 'VARIABLE_ENV')).toBe(1);
@@ -17,23 +17,23 @@ test('convertTimeStrToMs(exception)', () => {
1717
});
1818

1919
test('convertByteSizeToNumber', () => {
20-
expect(convertByteSizeToNumber('1024', 'VARIABLE_ENV')).toBe(1024);
21-
expect(convertByteSizeToNumber('1kb', 'VARIABLE_ENV')).toBe(1024);
22-
expect(convertByteSizeToNumber('10KB', 'VARIABLE_ENV')).toBe(10 * 1024);
23-
expect(convertByteSizeToNumber('1mb', 'VARIABLE_ENV')).toBe(1024 * 1024);
24-
expect(convertByteSizeToNumber('50MB', 'VARIABLE_ENV')).toBe(50 * 1024 * 1024);
25-
expect(convertByteSizeToNumber('1gb', 'VARIABLE_ENV')).toBe(1024 * 1024 * 1024);
26-
expect(convertByteSizeToNumber('2GB', 'VARIABLE_ENV')).toBe(2 * 1024 * 1024 * 1024);
20+
expect(convertSizeToBytes('1024', 'VARIABLE_ENV')).toBe(1024);
21+
expect(convertSizeToBytes('1kb', 'VARIABLE_ENV')).toBe(1024);
22+
expect(convertSizeToBytes('10KB', 'VARIABLE_ENV')).toBe(10 * 1024);
23+
expect(convertSizeToBytes('1mb', 'VARIABLE_ENV')).toBe(1024 * 1024);
24+
expect(convertSizeToBytes('50MB', 'VARIABLE_ENV')).toBe(50 * 1024 * 1024);
25+
expect(convertSizeToBytes('1gb', 'VARIABLE_ENV')).toBe(1024 * 1024 * 1024);
26+
expect(convertSizeToBytes('2GB', 'VARIABLE_ENV')).toBe(2 * 1024 * 1024 * 1024);
2727
});
2828

2929
test('convertByteSizeToNumber(exception)', () => {
30-
expect(() => convertByteSizeToNumber('', 'VARIABLE_ENV')).toThrowError(
30+
expect(() => convertSizeToBytes('', 'VARIABLE_ENV')).toThrowError(
3131
`Value "" is not valid for VARIABLE_ENV. Must be a number in bytes or size string (1kb, 1mb, 1gb).`
3232
);
33-
expect(() => convertByteSizeToNumber('abc', 'VARIABLE_ENV')).toThrowError(
33+
expect(() => convertSizeToBytes('abc', 'VARIABLE_ENV')).toThrowError(
3434
`Value "abc" is not valid for VARIABLE_ENV. Must be a number in bytes or size string (1kb, 1mb, 1gb).`
3535
);
36-
expect(() => convertByteSizeToNumber('1tb', 'VARIABLE_ENV')).toThrowError(
36+
expect(() => convertSizeToBytes('1tb', 'VARIABLE_ENV')).toThrowError(
3737
`Value "1tb" is not valid for VARIABLE_ENV. Must be a number in bytes or size string (1kb, 1mb, 1gb).`
3838
);
3939
});

0 commit comments

Comments
 (0)