(t *testing.T)
| 200 | } |
| 201 | |
| 202 | func TestCodeSQLReadOnlyBlocksSourceMutation(t *testing.T) { |
| 203 | source := t.TempDir() |
| 204 | writeTestFile(t, filepath.Join(source, "main.go"), `package main |
| 205 | |
| 206 | func 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 | |
| 242 | func TestCodeSQLLegacyConfigRejected(t *testing.T) { |
| 243 | source := t.TempDir() |
nothing calls this directly
no test coverage detected