srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/internal/store/store_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/store/store_test.go')
-rw-r--r--internal/store/store_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/internal/store/store_test.go b/internal/store/store_test.go
index 7999ac3..7fa985a 100644
--- a/internal/store/store_test.go
+++ b/internal/store/store_test.go
@@ -3,6 +3,8 @@ package store
import "testing"
func TestExtractStructured(t *testing.T) {
+ boolPtr := func(b bool) *bool { return &b }
+
tests := []struct {
name string
query string
@@ -10,6 +12,7 @@ func TestExtractStructured(t *testing.T) {
statusSQL string
statusArgs []any
source string
+ flagged *bool
}{
{
name: "plain text only",
@@ -17,6 +20,23 @@ func TestExtractStructured(t *testing.T) {
remaining: "admin login",
},
{
+ name: "flagged true",
+ query: "flagged:true",
+ remaining: "",
+ flagged: boolPtr(true),
+ },
+ {
+ name: "flagged false",
+ query: "flagged:no",
+ remaining: "",
+ flagged: boolPtr(false),
+ },
+ {
+ name: "not a real flagged token falls through as text",
+ query: "flagged:maybe",
+ remaining: "flagged:maybe",
+ },
+ {
name: "exact status",
query: "status:404",
remaining: "",
@@ -90,6 +110,13 @@ func TestExtractStructured(t *testing.T) {
if pred.source != tt.source {
t.Errorf("source = %q, want %q", pred.source, tt.source)
}
+ switch {
+ case pred.flagged == nil && tt.flagged == nil:
+ case pred.flagged == nil || tt.flagged == nil:
+ t.Errorf("flagged = %v, want %v", pred.flagged, tt.flagged)
+ case *pred.flagged != *tt.flagged:
+ t.Errorf("flagged = %v, want %v", *pred.flagged, *tt.flagged)
+ }
})
}
}