package repository

import (
	"testing"

	"go.mongodb.org/mongo-driver/bson"
)

func TestPriorityListFilterIncludesGoldInTrackFilters(t *testing.T) {
	relevant := priorityListFilter("relevant")
	inValues, ok := relevant["priority"].(bson.M)["$in"].([]string)
	if !ok {
		t.Fatalf("expected $in filter, got %v", relevant)
	}
	if len(inValues) != 2 || inValues[0] != "relevant" || inValues[1] != "gold" {
		t.Fatalf("unexpected relevant filter: %v", inValues)
	}

	recent := priorityListFilter("recent")
	inValues, ok = recent["priority"].(bson.M)["$in"].([]string)
	if !ok {
		t.Fatalf("expected $in filter, got %v", recent)
	}
	if len(inValues) != 2 || inValues[0] != "recent" || inValues[1] != "gold" {
		t.Fatalf("unexpected recent filter: %v", inValues)
	}

	gold := priorityListFilter("gold")
	if gold["priority"] != "gold" {
		t.Fatalf("expected exact gold filter, got %v", gold)
	}
}

func TestPriorityListFilterEmpty(t *testing.T) {
	if priorityListFilter("") != nil {
		t.Fatal("empty priority should not add filter")
	}
	if priorityListFilter("unknown") != nil {
		t.Fatal("unknown priority should not add filter")
	}
}
