oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1//go:build e2elive
2
3package e2elivetest
4
5import (
6 "database/sql"
7 "path/filepath"
8 "testing"
9)
10
11func liveSelfHealDiagnostics(t *testing.T, root string) {
12 t.Helper()
13 t.Cleanup(func() {
14 if !t.Failed() {
15 return
16 }
17 journal, err := sql.Open("sqlite", "file:"+filepath.Join(root, "state", "journal.db")+"?mode=ro")
18 if err != nil {
19 return
20 }
21 defer journal.Close()
22 for _, query := range []string{
23 `SELECT json_extract(body,'$.Kind'),count(*) FROM direct_events GROUP BY 1`,
24 `SELECT json_extract(body,'$.type'),json_extract(body,'$.subtype'),json_extract(body,'$.is_error'),json_extract(body,'$.stop_reason') FROM direct_frames WHERE json_extract(body,'$.type')='result'`,
25 } {
26 rows, err := journal.Query(query)
27 if err != nil {
28 continue
29 }
30 columns, _ := rows.Columns()
31 for rows.Next() {
32 values := make([]any, len(columns))
33 ptrs := make([]any, len(columns))
34 for i := range ptrs {
35 ptrs[i] = &values[i]
36 }
37 if rows.Scan(ptrs...) == nil {
38 t.Log("provider result metadata", values)
39 }
40 }
41 rows.Close()
42 }
43 })
44}
45