V0.38.2 library packages (#235)
Co-authored-by: gobha <jasafpro@gmail.com> Co-committed-by: gobha <jasafpro@gmail.com>
This commit is contained in:
@@ -233,5 +233,60 @@
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// ── v0.38.2: Library package validation ──
|
||||
|
||||
await T.test('packages', 'library-no-exports', 'library without exports → 400', async function () {
|
||||
var manifest = makeManifest({ type: 'library', tier: 'starlark' });
|
||||
delete manifest.tools;
|
||||
var file = makePkgFile(manifest, [
|
||||
{ name: 'script.star', content: 'x = 1\n' }
|
||||
]);
|
||||
try {
|
||||
await sw.api.admin.packages.install(file);
|
||||
T.assert(false, 'should have rejected library without exports');
|
||||
} catch (e) {
|
||||
var msg = (e && e.message) || String(e);
|
||||
T.assert(
|
||||
msg.indexOf('400') >= 0 || msg.indexOf('exports') >= 0 || msg.indexOf('error') >= 0,
|
||||
'expected 400 for missing exports'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
await T.test('packages', 'library-with-tools', 'library with tools → 400', async function () {
|
||||
var manifest = makeManifest({ type: 'library', tier: 'starlark', exports: ['fn1'] });
|
||||
// manifest already has tools from makeManifest
|
||||
var file = makePkgFile(manifest, [
|
||||
{ name: 'script.star', content: 'def fn1():\n return 1\n' }
|
||||
]);
|
||||
try {
|
||||
await sw.api.admin.packages.install(file);
|
||||
T.assert(false, 'should have rejected library with tools');
|
||||
} catch (e) {
|
||||
var msg = (e && e.message) || String(e);
|
||||
T.assert(
|
||||
msg.indexOf('400') >= 0 || msg.indexOf('tools') >= 0 || msg.indexOf('error') >= 0,
|
||||
'expected 400 for library with tools'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
await T.test('packages', 'consumer-bad-dep', 'consumer with non-existent dependency → 400', async function () {
|
||||
var manifest = makeManifest({ dependencies: { 'nonexistent-lib-xyz': '>=1.0.0' } });
|
||||
var file = makePkgFile(manifest, [
|
||||
{ name: 'script.star', content: 'def on_tool_call(call):\n return {"ok": True}\n' }
|
||||
]);
|
||||
try {
|
||||
await sw.api.admin.packages.install(file);
|
||||
T.assert(false, 'should have rejected non-existent dependency');
|
||||
} catch (e) {
|
||||
var msg = (e && e.message) || String(e);
|
||||
T.assert(
|
||||
msg.indexOf('400') >= 0 || msg.indexOf('not found') >= 0 || msg.indexOf('error') >= 0,
|
||||
'expected 400 for non-existent dependency'
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user