(t *testing.T)
| 28 | ) |
| 29 | |
| 30 | func TestNamespace(t *testing.T) { |
| 31 | a := assertions.New(t) |
| 32 | |
| 33 | mem := memory.New() |
| 34 | logger := log.NewLogger(mem) |
| 35 | |
| 36 | ctx := log.NewContext(test.Context(), logger) |
| 37 | |
| 38 | m := Namespace("test") |
| 39 | req := httptest.NewRequest(http.MethodGet, "/", nil).WithContext(ctx) |
| 40 | rec := httptest.NewRecorder() |
| 41 | m(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 42 | log.FromContext(r.Context()).Info("foobar") |
| 43 | entry := mem.Entries[0] |
| 44 | a.So(entry.Message(), should.Equal, "foobar") |
| 45 | fields := entry.Fields().Fields() |
| 46 | a.So(fields, should.HaveLength, 1) |
| 47 | a.So(fields["namespace"], should.Equal, "test") |
| 48 | })).ServeHTTP(rec, req) |
| 49 | } |
nothing calls this directly
no test coverage detected