(t *testing.T)
| 88 | } |
| 89 | |
| 90 | func TestNotifyWatcher_CollectionsUpdate(t *testing.T) { |
| 91 | t.Parallel() |
| 92 | |
| 93 | tmpDir, err := os.MkdirTemp("", "pb_notify_test*") |
| 94 | if err != nil { |
| 95 | t.Fatal(err) |
| 96 | } |
| 97 | defer os.RemoveAll(tmpDir) |
| 98 | |
| 99 | app1 := core.NewBaseApp(core.BaseAppConfig{ |
| 100 | DataDir: tmpDir, |
| 101 | }) |
| 102 | if err := app1.Bootstrap(); err != nil { |
| 103 | t.Fatal(err) |
| 104 | } |
| 105 | |
| 106 | app2 := core.NewBaseApp(core.BaseAppConfig{ |
| 107 | DataDir: tmpDir, |
| 108 | }) |
| 109 | if err := app2.Bootstrap(); err != nil { |
| 110 | t.Fatal(err) |
| 111 | } |
| 112 | |
| 113 | testQueries := store.New[string, []string](nil) |
| 114 | app2.ConcurrentDB().(*dbx.DB).QueryLogFunc = func(ctx context.Context, t time.Duration, sql string, rows *sql.Rows, err error) { |
| 115 | testQueries.SetFunc("concurrent", func(old []string) []string { |
| 116 | return append(old, sql) |
| 117 | }) |
| 118 | } |
| 119 | app2.ConcurrentDB().(*dbx.DB).ExecLogFunc = func(ctx context.Context, t time.Duration, sql string, result sql.Result, err error) { |
| 120 | testQueries.SetFunc("concurrent", func(old []string) []string { |
| 121 | return append(old, sql) |
| 122 | }) |
| 123 | } |
| 124 | app2.NonconcurrentDB().(*dbx.DB).QueryLogFunc = func(ctx context.Context, t time.Duration, sql string, rows *sql.Rows, err error) { |
| 125 | testQueries.SetFunc("nonconcurrent", func(old []string) []string { |
| 126 | return append(old, sql) |
| 127 | }) |
| 128 | } |
| 129 | app2.NonconcurrentDB().(*dbx.DB).ExecLogFunc = func(ctx context.Context, t time.Duration, sql string, result sql.Result, err error) { |
| 130 | testQueries.SetFunc("nonconcurrent", func(old []string) []string { |
| 131 | return append(old, sql) |
| 132 | }) |
| 133 | } |
| 134 | |
| 135 | ctx, cancelCtx := context.WithTimeout(context.Background(), 1*time.Second) |
| 136 | defer cancelCtx() |
| 137 | |
| 138 | sem := semaphore.NewWeighted(1) |
| 139 | sem.Acquire(ctx, 1) |
| 140 | |
| 141 | // currently there is no hook for the collections cache reload so we pool instead |
| 142 | done := make(chan bool, 1) |
| 143 | ticker := time.NewTicker(100 * time.Millisecond) |
| 144 | go func() { |
| 145 | for { |
| 146 | select { |
| 147 | case <-ticker.C: |
nothing calls this directly
no test coverage detected
searching dependent graphs…