Skip to content

Commit

Permalink
fix: Replace 'vCPU' with 'vcpus'
Browse files Browse the repository at this point in the history
GCE shows vCPU in the description of the machine, not the vcpus.

Refs: HMS-2301
  • Loading branch information
stejskalleos authored and ezr-ondrej committed Oct 31, 2023
1 parent d1cbba3 commit 1c11b5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Utils/querySearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ const jsonata = require('jsonata');

const OPERATORS = ['<', '>', '='];

const parseQuery = (query) => {
export const parseQuery = (query) => {
query = query.replace('memory', 'memory_mib');
query = query.replace('storage', 'storage_gb');
query = query.replace(/vcpu(\W|$)/i, 'vcpus$1');
if (OPERATORS.every((operator) => !query.includes(operator))) {
query = `name ~> /${query}/i`;
}
Expand Down
9 changes: 9 additions & 0 deletions src/Utils/querySearch.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { parseQuery } from './querySearch';

describe('parseQuery', () => {
test('replaces vcpu by vcpus', async () => {
expect(parseQuery('vcpu > 2')).toBe('types[vcpus > 2]');
expect(parseQuery('vcpu> 2')).toBe('types[vcpus> 2]');
expect(parseQuery('vCPU > 2')).toBe('types[vcpus > 2]');
});
});

0 comments on commit 1c11b5b

Please sign in to comment.