MCPcopy
hub / github.com/google/mtail / TestCompileAndRun

Function TestCompileAndRun

internal/runtime/runtime_test.go:42–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestCompileAndRun(t *testing.T) {
43 testProgram := "/$/ {}\n"
44 store := metrics.NewStore()
45 lines := make(chan *logline.LogLine)
46 var wg sync.WaitGroup
47 l, err := New(lines, &wg, "", store)
48 testutil.FatalIfErr(t, err)
49 if err := l.CompileAndRun("Test", strings.NewReader(testProgram)); err != nil {
50 t.Errorf("CompileAndRun returned error: %s", err)
51 }
52 l.handleMu.Lock()
53 if len(l.handles) < 1 {
54 t.Errorf("no vm handles: %v", l.handles)
55 }
56 l.handleMu.Unlock()
57 l.handleMu.Lock()
58 h := l.handles["Test"]
59 if h == nil {
60 t.Errorf("No handle for Test: %v", l.handles)
61 }
62 l.handleMu.Unlock()
63 close(lines)
64 wg.Wait()
65}
66
67var testProgram = "/$/ {}\n"
68

Callers

nothing calls this directly

Calls 4

NewStoreFunction · 0.92
FatalIfErrFunction · 0.92
CompileAndRunMethod · 0.80
NewFunction · 0.50

Tested by

no test coverage detected