package pack

import "testing"

func TestResolveApplicableHostOverlays(t *testing.T) {
	provider := ProviderManifest{
		ProviderID: "kimi-a7m",
		HostOverlays: []HostOverlay{
			{
				OverlayID:      "sub2api-stock-v0129-kimi-a7m",
				DisplayName:    "sub2api stock v0.1.129 Kimi A7M overlay",
				TargetHost:     "sub2api",
				MinHostVersion: "0.1.129",
				MaxHostVersion: "0.1.129",
				Reason:         "stock host still routes chat traffic into unsupported Responses path",
			},
			{
				OverlayID:      "other-version",
				DisplayName:    "other version",
				TargetHost:     "sub2api",
				MinHostVersion: "0.1.130",
				MaxHostVersion: "0.1.130",
				Reason:         "not this version",
			},
		},
	}

	overlays, err := ResolveApplicableHostOverlays(provider, "sub2api", "0.1.129")
	if err != nil {
		t.Fatalf("ResolveApplicableHostOverlays() error = %v", err)
	}
	if len(overlays) != 1 || overlays[0].OverlayID != "sub2api-stock-v0129-kimi-a7m" {
		t.Fatalf("ResolveApplicableHostOverlays() = %+v, want matching v0.1.129 overlay", overlays)
	}
}
