feat: filter and search by tag
This commit is contained in:
@ -277,3 +277,31 @@ func TestHandlerTags_Remove(t *testing.T) {
|
||||
t.Fatalf("expected tag to be removed, got %+v", n.Tags)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlerRoot_TagFilter(t *testing.T) {
|
||||
env := newTestEnv(t)
|
||||
|
||||
if err := env.storage.AddTag("a1", "go"); err != nil {
|
||||
t.Fatalf("seed tag: %v", err)
|
||||
}
|
||||
if err := env.storage.AddTag("b2", "rust"); err != nil {
|
||||
t.Fatalf("seed tag: %v", err)
|
||||
}
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/?tag=go", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
env.handler.ServeHTTP(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("expected status 200, got %d", rec.Code)
|
||||
}
|
||||
|
||||
body := rec.Body.String()
|
||||
if strings.Contains(body, noteMarker("b2")) {
|
||||
t.Fatalf("expected non-matching note to be excluded")
|
||||
}
|
||||
if !strings.Contains(body, noteMarker("a1")) {
|
||||
t.Fatalf("expected matching note to be included")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user