MCPcopy
hub / github.com/dosco/graphjin / TestCodeSQLMultiDBInitializesManagedSQLiteRuntime

Function TestCodeSQLMultiDBInitializesManagedSQLiteRuntime

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

Source from the content-addressed store, hash-verified

14)
15
16func TestCodeSQLMultiDBInitializesManagedSQLiteRuntime(t *testing.T) {
17 source := t.TempDir()
18 writeTestFile(t, filepath.Join(source, "main.go"), `package main
19
20func Handler() {}
21`)
22
23 conf := &Config{
24 Core: Core{
25 Sources: []core.SourceConfig{
26 {Name: "code", Kind: "code", Path: source},
27 },
28 },
29 Serv: Serv{
30 ConfigPath: filepath.Join(t.TempDir(), "config"),
31 MCP: MCPConfig{Disable: true},
32 },
33 }
34
35 s, err := newGraphJinService(conf, nil)
36 if err != nil {
37 t.Fatal(err)
38 }
39 defer closeTestService(s)
40
41 if got := s.conf.Core.Databases["code"].Type; got != "codesql" {
42 t.Fatalf("logical config type = %q, want codesql", got)
43 }
44 runtime := s.runtimeCore.Databases["code"]
45 if runtime.Type != "sqlite" {
46 t.Fatalf("runtime type = %q, want sqlite", runtime.Type)
47 }
48 if !runtime.ReadOnly {
49 t.Fatalf("runtime read_only = false, want true")
50 }
51 if runtime.AnalyticsMode == nil || !*runtime.AnalyticsMode {
52 t.Fatalf("runtime analytics_mode = %v, want true", runtime.AnalyticsMode)
53 }
54 if !strings.HasPrefix(filepath.Base(runtime.Path), "code-") {
55 t.Fatalf("cache filename = %q, want database-name prefix", filepath.Base(runtime.Path))
56 }
57 assertGraphJinTable(t, s, "code", "gj_code")
58 assertServiceCount(t, s, "code", `SELECT count(*) FROM gj_code WHERE kind = 'symbol' AND name = 'Handler'`, 1)
59 if managed := s.managedDBs["code"]; !managed.watch {
60 t.Fatalf("codesql watcher disabled in development, want enabled")
61 }
62}
63
64func TestCodeSQLRelativePathResolvesFromConfigPath(t *testing.T) {
65 configRoot := t.TempDir()

Callers

nothing calls this directly

Calls 5

writeTestFileFunction · 0.85
newGraphJinServiceFunction · 0.85
closeTestServiceFunction · 0.85
assertGraphJinTableFunction · 0.85
assertServiceCountFunction · 0.85

Tested by

no test coverage detected