Feat v0.7.2 package runners ci gate (#56)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-runners (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-go-pg (push) Successful in 2m39s
CI/CD / test-sqlite (push) Successful in 2m55s
CI/CD / build-and-deploy (push) Successful in 29s
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-runners (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-go-pg (push) Successful in 2m39s
CI/CD / test-sqlite (push) Successful in 2m55s
CI/CD / build-and-deploy (push) Successful in 29s
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #56.
This commit is contained in:
65
packages/schedules-runner/js/schedules-crud.js
Normal file
65
packages/schedules-runner/js/schedules-crud.js
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Schedules Runner — schedules/crud suite
|
||||
*
|
||||
* Tests schedule CRUD via the kernel schedules API.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var API = window.SR.api;
|
||||
|
||||
sw.testing.suite('schedules/crud', async function (s) {
|
||||
var schedId;
|
||||
|
||||
s.test('create schedule', async function (t) {
|
||||
var r = await sw.api.post(API, {
|
||||
name: 'runner-test-' + Date.now(),
|
||||
cron_expr: '0 0 * * *',
|
||||
script: 'print("hello from schedule runner")',
|
||||
enabled: false
|
||||
});
|
||||
t.assert.ok(r.id, 'schedule has id');
|
||||
t.assert.ok(r.name, 'schedule has name');
|
||||
schedId = r.id;
|
||||
s.track('schedule', schedId);
|
||||
});
|
||||
|
||||
s.test('get schedule', async function (t) {
|
||||
t.assert.ok(schedId, 'schedId from previous test');
|
||||
var r = await sw.api.get(API + '/' + schedId);
|
||||
t.assert.eq(r.id, schedId, 'id matches');
|
||||
t.assert.ok(r.cron_expr, 'cron_expr present');
|
||||
});
|
||||
|
||||
s.test('update schedule', async function (t) {
|
||||
t.assert.ok(schedId, 'schedId from previous test');
|
||||
var r = await sw.api.put(API + '/' + schedId, {
|
||||
name: 'runner-test-updated',
|
||||
cron_expr: '30 2 * * *'
|
||||
});
|
||||
t.assert.eq(r.name, 'runner-test-updated', 'name updated');
|
||||
});
|
||||
|
||||
s.test('run schedule', async function (t) {
|
||||
t.assert.ok(schedId, 'schedId from previous test');
|
||||
try {
|
||||
await sw.api.post(API + '/' + schedId + '/run', {});
|
||||
t.assert.ok(true, 'run endpoint returned successfully');
|
||||
} catch (e) {
|
||||
t.warn('Schedule run failed: ' + e.message);
|
||||
}
|
||||
});
|
||||
|
||||
s.test('delete schedule', async function (t) {
|
||||
t.assert.ok(schedId, 'schedId from previous test');
|
||||
await sw.api.del(API + '/' + schedId);
|
||||
try {
|
||||
await sw.api.get(API + '/' + schedId);
|
||||
t.assert.ok(false, 'expected error after delete');
|
||||
} catch (e) {
|
||||
t.assert.ok(true, 'schedule not found after delete');
|
||||
}
|
||||
schedId = null;
|
||||
});
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user