MCPcopy Index your code
hub / github.com/supabase/auth / TestWatchNotify

Function TestWatchNotify

internal/reloader/reloader_test.go:124–605  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

122}
123
124func TestWatchNotify(t *testing.T) {
125 ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
126 defer cancel()
127
128 t.Run("IsWatchable", func(t *testing.T) {
129 dir, cleanup := helpTestDir(t)
130 defer cleanup()
131
132 invalidDir := path.Join(dir, "__not_found__")
133 require.False(t, isWatchable(invalidDir))
134
135 name := helpWriteEnvFile(t, dir, "05_example.env", map[string]string{
136 "GOTRUE_SMTP_PORT": "2222",
137 })
138 require.False(t, isWatchable(name))
139
140 })
141
142 t.Run("AllDisabled", func(t *testing.T) {
143 dir, cleanup := helpTestDir(t)
144 defer cleanup()
145
146 rr := mockReloadRecorder()
147
148 cfg := e2e.Must(e2e.Config()).Reloading
149 cfg.NotifyEnabled = false
150 cfg.SignalEnabled = false
151 cfg.PollerEnabled = false
152
153 rl := NewReloader(cfg, dir)
154
155 err := rl.Watch(ctx, rr.configFn)
156 require.NoError(t, err)
157 })
158
159 t.Run("BrokenWatcher", func(t *testing.T) {
160 dir, cleanup := helpTestDir(t)
161 defer cleanup()
162
163 sentinelErr := errors.New("sentinel")
164 rr := mockReloadRecorder()
165
166 cfg := e2e.Must(e2e.Config()).Reloading
167 cfg.SignalEnabled = false
168 cfg.PollerEnabled = false
169
170 rl := NewReloader(cfg, dir)
171 rl.watchFn = func() (watcher, error) { return nil, sentinelErr }
172
173 err := rl.Watch(ctx, rr.configFn)
174 if exp, got := sentinelErr, err; exp != got {
175 require.Equal(t, exp, got)
176 }
177 })
178
179 t.Run("InvalidDir", func(t *testing.T) {
180 dir, cleanup := helpTestDir(t)
181 defer cleanup()

Callers

nothing calls this directly

Calls 15

WatchMethod · 0.95
watchPollerMethod · 0.95
MustFunction · 0.92
ConfigFunction · 0.92
helpTestDirFunction · 0.85
isWatchableFunction · 0.85
helpWriteEnvFileFunction · 0.85
mockReloadRecorderFunction · 0.85
NewReloaderFunction · 0.85
newMockWatcherFunction · 0.85
runUntilErrorStrFunction · 0.85
helpCopyEnvFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…