Skip to content

Commit d3524b8

Browse files
auxesisclaude
andcommitted
test: guard the Go module path
go vet catches an import of the old suite module path, but not a stale go get line or pkg.go.dev link in a README. Check that go.mod declares the stack path, and that no tracked file outside docs/plans/ names the suite path, so the cutover re-export cannot bring it back unnoticed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PaY5xYydZUWhv8Nex9Sw8a
1 parent a981590 commit d3524b8

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { execFileSync } from 'node:child_process'
2+
import { readFileSync } from 'node:fs'
3+
import { join } from 'node:path'
4+
import { describe, expect, it } from 'vitest'
5+
import { REPO_ROOT } from './lib/repo-root.mjs'
6+
7+
/**
8+
* The Go module lives at its stack path. The suite's path named a private
9+
* repository whose `bindings/go` folder the suite removal deletes, so a
10+
* `go get` of it can never resolve.
11+
*
12+
* `go vet` catches a stale import, but not a stale `go get` line or
13+
* pkg.go.dev link in a README. The cutover re-export can bring those back in
14+
* new or changed files, which is why the text check covers every tracked file.
15+
* `docs/plans/` keeps the old path as history.
16+
*/
17+
18+
const MODULE = 'github.com/cipherstash/stack/languages/golang'
19+
const SUITE_MODULE = 'github.com/cipherstash/cipherstash-suite/bindings/go'
20+
const SELF = 'scripts/__tests__/go-module-path.test.mjs'
21+
22+
function filesNaming(needle) {
23+
try {
24+
return execFileSync(
25+
'git',
26+
['grep', '-l', '-F', needle, '--', '.', ':!docs/plans/', `:!${SELF}`],
27+
{ cwd: REPO_ROOT, encoding: 'utf8' },
28+
)
29+
.split('\n')
30+
.filter(Boolean)
31+
} catch (error) {
32+
// git grep exits 1 when nothing matches.
33+
if (error.status === 1) return []
34+
throw error
35+
}
36+
}
37+
38+
describe('Go module path', () => {
39+
it('go.mod declares the stack path', () => {
40+
const goMod = readFileSync(
41+
join(REPO_ROOT, 'languages/golang/go.mod'),
42+
'utf8',
43+
)
44+
expect(goMod.split('\n')[0]).toBe(`module ${MODULE}`)
45+
})
46+
47+
it('no tracked file outside docs/plans/ names the suite path', () => {
48+
expect(filesNaming(SUITE_MODULE)).toEqual([])
49+
})
50+
51+
it('the text check sees a match when there is one', () => {
52+
expect(filesNaming(MODULE)).toContain('languages/golang/go.mod')
53+
})
54+
})

0 commit comments

Comments
 (0)