Skip to content

Commit

Permalink
minifyCriteria moved to separate test files
Browse files Browse the repository at this point in the history
  • Loading branch information
Houwie7000 committed Jan 19, 2025
1 parent 47cb0fd commit 39ce2fa
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 7 deletions.
125 changes: 125 additions & 0 deletions Framework/Backend/test/mocha-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/**
* @license
* Copyright 2019-2020 CERN and copyright holders of ALICE O2.
* See http://alice-o2.web.cern.ch/copyright for details of the copyright holders.
* All rights not expressly granted are reserved.
*
* This software is distributed under the terms of the GNU General Public
* License v3 (GPL Version 3), copied verbatim in the file "COPYING".
*
* In applying this license CERN does not waive the privileges and immunities
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/
const assert = require('assert');
const { minifyCriteria } = require('../utils/minifyCriteria.js');

const filters = {
timestamp: {
since: '13:02:30',
until: '13:02:40',
$since: '2024-12-02T12:02:30.000Z',
$until: '2024-12-02T12:02:40.000Z',
},
hostname: {
match: 'aldaqecs01-v1',
exclude: '',
$match: 'aldaqecs01-v1',
$exclude: null,
},
rolename: {
match: '',
exclude: '',
$match: null,
$exclude: null,
},
pid: {
match: '50990',
exclude: '',
$match: '50990',
$exclude: null,
},
username: {
match: 'alicedaq',
exclude: '',
$match: 'alicedaq',
$exclude: null,
},
system: {
match: 'DAQ',
exclude: '',
$match: 'DAQ',
$exclude: null,
},
facility: {
match: 'runControl',
exclude: '',
$match: 'runControl',
$exclude: null,
},
detector: {
match: 'TPC',
exclude: '',
$match: 'TPC',
$exclude: null,
},
partition: {
match: '',
exclude: '',
$match: null,
$exclude: null,
},
run: {
match: '248023',
exclude: '',
$match: '248023',
$exclude: null,
},
errcode: {
match: '',
exclude: '',
$match: null,
$exclude: null,
},
errline: {
match: '',
exclude: '',
$match: null,
$exclude: null,
},
errsource: {
match: '',
exclude: '',
$match: null,
$exclude: null,
},
message: {
match: '',
exclude: '',
$match: null,
$exclude: null,
},
severity: {
in: 'I F',
$in: [
'I',
'F',
],
},
level: {
max: null,
$max: null,
},
};

const minifiedFilters = '{"timestamp":{"since":"13:02:30","until":"13:02:40"},"hostname":{"match":"aldaqecs01-v1"},' +
'"pid":{"match":"50990"},"username":{"match":"alicedaq"},"system":{"match":"DAQ"},"facility":{"match":"runControl"},' +
'"detector":{"match":"TPC"},"run":{"match":"248023"},"severity":{"in":"I F"}}';

describe('Utils - minifyCriteria()', () => {
it('minifyCriteria() works as expected', (done) => {
const criterias = minifyCriteria(filters);
assert.strictEqual(JSON.stringify(criterias), minifiedFilters);
done();
});
});
7 changes: 0 additions & 7 deletions Framework/Backend/test/mocha-ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const HttpServer = require('./../http/server');
const O2TokenService = require('./../services/O2TokenService.js');
const sinon = require('sinon');
const WebSocketMessage = require('./../websocket/message.js');
const { minifyCriteria } = require('../utils/minifyCriteria.js');

process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

Expand Down Expand Up @@ -265,12 +264,6 @@ describe('websocket', () => {
});
});

it('minifyCriteria() works as expected', (done) => {
const criterias = minifyCriteria(filters);
assert.strictEqual(JSON.stringify(criterias), minifiedFilters);
done();
});

it('Request message broadcast with 200', (done) => {
const connection = new WsClient(`ws://localhost:${config.http.port}/?token=${token}`);

Expand Down

0 comments on commit 39ce2fa

Please sign in to comment.