MCPcopy
hub / github.com/perkeep/perkeep / TestInstallHandlers

Function TestInstallHandlers

pkg/serverinit/serverinit_test.go:279–422  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

277}
278
279func TestInstallHandlers(t *testing.T) {
280 srcRoot, err := osutil.PkSourceRoot()
281 if err != nil {
282 t.Fatalf("source root folder not found: %v", err)
283 }
284 conf := serverinit.DefaultBaseConfig
285 conf.Identity = "26F5ABDA"
286 conf.IdentitySecretRing = filepath.Join(srcRoot, filepath.FromSlash("pkg/jsonsign/testdata/test-secring.gpg"))
287 conf.MemoryStorage = true
288 conf.MemoryIndex = true
289
290 confData, err := json.MarshalIndent(conf, "", " ")
291 if err != nil {
292 t.Fatalf("Could not json encode config: %v", err)
293 }
294
295 // Setting CAMLI_CONFIG_DIR to avoid triggering failInTests in osutil.PerkeepConfigDir
296 t.Setenv("CAMLI_CONFIG_DIR", "whatever")
297 lowConf, err := serverinit.Load(confData)
298 if err != nil {
299 t.Fatal(err)
300 }
301
302 hi := http.NewServeMux()
303 address := "http://" + conf.Listen
304 _, err = lowConf.InstallHandlers(hi, address)
305 if err != nil {
306 t.Fatal(err)
307 }
308
309 tests := []struct {
310 prefix string
311 authWrapped bool
312 prefixWrapped bool
313 handlerType reflect.Type
314 }{
315 {
316 prefix: "/",
317 handlerType: reflect.TypeOf(&server.RootHandler{}),
318 prefixWrapped: true,
319 },
320
321 {
322 prefix: "/sync/",
323 handlerType: reflect.TypeOf(&server.SyncHandler{}),
324 prefixWrapped: true,
325 authWrapped: true,
326 },
327
328 {
329 prefix: "/my-search/",
330 handlerType: reflect.TypeOf(&search.Handler{}),
331 prefixWrapped: true,
332 authWrapped: true,
333 },
334
335 {
336 prefix: "/ui/",

Callers

nothing calls this directly

Calls 8

PkSourceRootFunction · 0.92
LoadFunction · 0.92
FatalMethod · 0.80
InstallHandlersMethod · 0.80
NewRequestMethod · 0.80
HandlerMethod · 0.80
FatalfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected