|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright 2019-2020 CERN and copyright holders of ALICE O2. |
| 4 | + * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 5 | + * All rights not expressly granted are reserved. |
| 6 | + * |
| 7 | + * This software is distributed under the terms of the GNU General Public |
| 8 | + * License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 9 | + * |
| 10 | + * In applying this license CERN does not waive the privileges and immunities |
| 11 | + * granted to it by virtue of its status as an Intergovernmental Organization |
| 12 | + * or submit itself to any jurisdiction. |
| 13 | + */ |
| 14 | + |
| 15 | +import { suite, test } from 'node:test'; |
| 16 | +import { URL_ADDRESS, OWNER_TEST_TOKEN } from '../config.js'; |
| 17 | +import request from 'supertest'; |
| 18 | + |
| 19 | +export const apiGetRunStatusTests = () => { |
| 20 | + suite('GET /filter/run-status/:runNumber', () => { |
| 21 | + test('should return a 403 error if no authentication token is provided', async () => { |
| 22 | + await request(`${URL_ADDRESS}/api/filter/run-status/123456`) |
| 23 | + .get('') |
| 24 | + .expect(403); |
| 25 | + }); |
| 26 | + |
| 27 | + test('should return a 404 error if run number is not provided', async () => { |
| 28 | + await request(`${URL_ADDRESS}/api/filter/run-status/`) |
| 29 | + .get(`?token=${OWNER_TEST_TOKEN}`) |
| 30 | + .expect(404, { |
| 31 | + error: '404 - Page not found', |
| 32 | + message: 'The requested URL was not found on this server.', |
| 33 | + }); |
| 34 | + }); |
| 35 | + |
| 36 | + test('should return a 400 error for invalid run number (negative)', async () => { |
| 37 | + await request(`${URL_ADDRESS}/api/filter/run-status/-1`) |
| 38 | + .get(`?token=${OWNER_TEST_TOKEN}`) |
| 39 | + .expect(400, { |
| 40 | + message: 'Run number must be positive', |
| 41 | + status: 400, |
| 42 | + title: 'Invalid Input', |
| 43 | + }); |
| 44 | + }); |
| 45 | + |
| 46 | + test('should return a 400 error for invalid run number (too large)', async () => { |
| 47 | + await request(`${URL_ADDRESS}/api/filter/run-status/1000000`) |
| 48 | + .get(`?token=${OWNER_TEST_TOKEN}`) |
| 49 | + .expect(400, { |
| 50 | + message: 'Run number must not exceed 999999', |
| 51 | + status: 400, |
| 52 | + title: 'Invalid Input', |
| 53 | + }); |
| 54 | + }); |
| 55 | + |
| 56 | + test('should return a 400 error for invalid run number (not a number)', async () => { |
| 57 | + await request(`${URL_ADDRESS}/api/filter/run-status/invalid`) |
| 58 | + .get(`?token=${OWNER_TEST_TOKEN}`) |
| 59 | + .expect(400, { |
| 60 | + message: 'Run number must be a number', |
| 61 | + status: 400, |
| 62 | + title: 'Invalid Input', |
| 63 | + }); |
| 64 | + }); |
| 65 | + |
| 66 | + test('should successfully get run status for valid run number', async () => { |
| 67 | + await request(`${URL_ADDRESS}/api/filter/run-status/123456`) |
| 68 | + .get(`?token=${OWNER_TEST_TOKEN}`) |
| 69 | + .expect(200); |
| 70 | + }); |
| 71 | + }); |
| 72 | +}; |
0 commit comments