MCPcopy Create free account
hub / github.com/ankorstore/yokai / TestModuleWithDebugConfigEnabled

Function TestModuleWithDebugConfigEnabled

fxcore/module_test.go:466–507  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

464}
465
466func TestModuleWithDebugConfigEnabled(t *testing.T) {
467 t.Setenv("APP_CONFIG_PATH", "testdata/config")
468 t.Setenv("CONFIG_ENABLED", "true")
469 t.Setenv("METRICS_ENABLED", "true")
470 t.Setenv("METRICS_COLLECT", "true")
471
472 var core *fxcore.Core
473 var logBuffer logtest.TestLogBuffer
474 var traceExporter tracetest.TestTraceExporter
475
476 fxcore.NewBootstrapper().RunTestApp(t, fx.Populate(&core, &logBuffer, &traceExporter))
477
478 // [GET] /debug/config
479 req := httptest.NewRequest(http.MethodGet, "/debug/config", nil)
480 rec := httptest.NewRecorder()
481 core.HttpServer().ServeHTTP(rec, req)
482
483 assert.Equal(t, http.StatusOK, rec.Code)
484 assert.Contains(
485 t,
486 strings.ReplaceAll(strings.ReplaceAll(rec.Body.String(), " ", ""), "\n", ""),
487 `"name":"core-app"`,
488 )
489
490 logtest.AssertHasLogRecord(t, logBuffer, map[string]interface{}{
491 "level": "info",
492 "service": "core-app",
493 "module": "core",
494 "uri": "/debug/config",
495 "status": 200,
496 "message": "request logger",
497 })
498
499 tracetest.AssertHasTraceSpan(
500 t,
501 traceExporter,
502 "GET /debug/config",
503 semconv.HTTPMethod(http.MethodGet),
504 semconv.HTTPRoute("/debug/config"),
505 semconv.HTTPStatusCode(http.StatusOK),
506 )
507}
508
509func TestModuleWithDebugPprofDisabled(t *testing.T) {
510 t.Setenv("APP_CONFIG_PATH", "testdata/config")

Callers

nothing calls this directly

Calls 3

HttpServerMethod · 0.95
RunTestAppMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected