MCPcopy Index your code
hub / github.com/dosco/graphjin / TestCodeSQLReadOnlyBlocksSourceMutation

Function TestCodeSQLReadOnlyBlocksSourceMutation

serv/codesql_test.go:202–240  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

200}
201
202func TestCodeSQLReadOnlyBlocksSourceMutation(t *testing.T) {
203 source := t.TempDir()
204 writeTestFile(t, filepath.Join(source, "main.go"), `package main
205
206func Handler() {}
207`)
208
209 conf := &Config{
210 Core: Core{
211 DisableAllowList: true,
212 Sources: []core.SourceConfig{
213 {Name: "code", Kind: "code", Path: source, ReadOnly: true},
214 },
215 },
216 Serv: Serv{
217 ConfigPath: filepath.Join(t.TempDir(), "config"),
218 MCP: MCPConfig{Disable: true},
219 },
220 }
221
222 s, err := newGraphJinService(conf, nil)
223 if err != nil {
224 t.Fatal(err)
225 }
226 defer closeTestService(s)
227
228 _, err = s.gj.GraphQL(context.Background(), `mutation {
229 gj_code(insert: {
230 kind: "lock",
231 action: "acquire",
232 path: "main.go",
233 owner: "test",
234 ranges: [{ start_byte: 0, end_byte: 20 }]
235 }) { id status }
236 }`, nil, nil)
237 if err == nil || !strings.Contains(err.Error(), "read-only") {
238 t.Fatalf("source mutation err = %v, want read-only block", err)
239 }
240}
241
242func TestCodeSQLLegacyConfigRejected(t *testing.T) {
243 source := t.TempDir()

Callers

nothing calls this directly

Calls 5

writeTestFileFunction · 0.85
newGraphJinServiceFunction · 0.85
closeTestServiceFunction · 0.85
ErrorMethod · 0.65
GraphQLMethod · 0.45

Tested by

no test coverage detected