fix(cso): report a go.mod repository as Go (unsupported), not Python (#3263)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-10-24 20:29:18 +00:00
1 parent 00100f1598
commit e09e614945
4 files changed
+55 -6

No files matched your search

+26
View File
@@ -170,6 +170,32 @@ describe('CSO inert Python preparation', () => {
});
});
describe('CSO preparation names a Go module as Go (#3263)', () => {
const goFiles = {
'go.mod': 'module example.com/app\n\ngo 1.23\n\nrequire github.com/google/uuid v1.6.0\n',
'go.sum': 'github.com/google/uuid v1.6.0 h1:abc=\n',
'main.go': 'package main\n\nfunc main() {}\n',
};
const GO_UNSUPPORTED = { code: 'UNSUPPORTED_STACK', message: 'Go (go.mod) is not a supported runtime stack yet; supported runtime stacks are Node, Bun, Python, and Rails.', path: 'go.mod' };
test('a go.mod repository is Go, unsupported, and never asks for requirements.txt', () => {
const plan = inspectPreparation(fixture(goFiles));
expect([plan.stack, plan.runtimeProfile, plan.status]).toEqual(['go', 'go', 'prerequisites']);
expect(plan.prerequisites).toEqual([GO_UNSUPPORTED]);
expect(JSON.stringify(plan)).not.toContain('requirements.txt');
});
test('Python helper metadata beside go.mod stays Go', () => {
const plan = inspectPreparation(fixture({ ...goFiles, 'requirements.txt': `mkdocs==1.6.1 --hash=sha256:${hash}\n` }));
expect(plan.stack).toBe('go');
expect(plan.prerequisites).toEqual([GO_UNSUPPORTED]);
});
test('controls: go.mod beside a Node lockfile stays Node; Python without go.mod stays Python', () => {
const node = inspectPreparation(fixture({ ...goFiles, ...nodeFiles() }));
expect([node.stack, node.status]).toEqual(['node', 'ready']);
expect(inspectPreparation(fixture({ 'requirements.txt': `Flask==3.1.0 --hash=sha256:${hash}\n` })).stack).toBe('python');
expect(inspectPreparation(fixture({ 'go.sum': '', 'main.go': '' })).stack).toBe('python');
});
});
describe('CSO inert Rails preparation', () => {
test('does not silently choose Node in a multi-stack repository',()=>{const plan=inspectPreparation(fixture({...nodeFiles(),'Gemfile.lock':gemLock,'Gemfile':''}));expect(plan.status).toBe('prerequisites');expect(plan.prerequisites[0].code).toBe('MULTIPLE_STACKS');expect(inspectPreparation(fixture({...nodeFiles(),'Gemfile.lock':gemLock,'Gemfile':''}),'rails').stack).toBe('rails');});
test('fetches exact gems without evaluating Gemfiles or building native extensions', () => {
+1 -1
View File
@@ -1,6 +1,6 @@
import type { CsoStack } from '../../lib/cso/preparation';
type RuntimeStack = Exclude<CsoStack, 'java'>;
type RuntimeStack = Exclude<CsoStack, 'java' | 'go'>;
import { canonical, sha256 } from '../../lib/cso/contracts';
import { ISOLATION_POLICY_HASH } from '../../lib/cso/docker';
import {