Carry optional prompt labels through results

This commit is contained in:
2026-10-17 05:54:32 +00:00
parent 8cbb7c0daf
commit ec3245c97e
40 changed files with 363 additions and 121 deletions

View File

@@ -38,13 +38,13 @@ func TestListIdentitiesBasicContract(t *testing.T) {
t.Fatal(err)
}
want := []promptkit.PromptIdentity{
{ID: "example-prompt", Version: "10"},
{ID: "example-prompt", Version: stringPointerForTest("10")},
}
if len(prompts) != len(want) {
t.Fatalf("prompt listing = %#v, want %#v", prompts, want)
}
for i := range want {
if prompts[i] != want[i] {
if prompts[i].ID != want[i].ID || prompts[i].Version == nil || *prompts[i].Version != *want[i].Version {
t.Fatalf("prompt listing = %#v, want %#v", prompts, want)
}
}
@@ -54,7 +54,8 @@ func TestListIdentitiesBasicContract(t *testing.T) {
t.Fatalf("listed profile could not be inspected: (%+v, %v)", profile, err)
}
prompt, err := engine.InspectPrompt(context.Background(), prompts[0].ID)
if err != nil || prompt == nil || prompt.PromptID != prompts[0].ID || prompt.PromptVersion != prompts[0].Version {
if err != nil || prompt == nil || prompt.PromptID != prompts[0].ID || prompt.PromptVersion == nil ||
*prompt.PromptVersion != *prompts[0].Version {
t.Fatalf("listed prompt could not be inspected: (%+v, %v)", prompt, err)
}
}
@@ -169,9 +170,9 @@ func TestListIdentitiesUseEffectiveLayeredMembership(t *testing.T) {
t.Fatal(err)
}
wantPrompts := []promptkit.PromptIdentity{
{ID: "main-only", Version: "v3"},
{ID: "shared/prompt", Version: "v2"},
{ID: "underlay-only", Version: "v1"},
{ID: "main-only", Version: stringPointerForTest("v3")},
{ID: "shared/prompt", Version: stringPointerForTest("v2")},
{ID: "underlay-only", Version: stringPointerForTest("v1")},
}
if !reflect.DeepEqual(prompts, wantPrompts) {
t.Fatalf("effective prompt identities = %#v, want %#v", prompts, wantPrompts)
@@ -225,7 +226,9 @@ func TestListIdentitiesAreOwnedAndSafeForConcurrentUse(t *testing.T) {
for i := range prompts {
if prompts[i].ID == "prompt" {
prompts[i].ID = "caller mutation"
prompts[i].Version = "caller mutation"
if prompts[i].Version != nil {
*prompts[i].Version = "caller mutation"
}
}
}
profiles, err = engine.ListProfiles(context.Background())
@@ -269,7 +272,9 @@ func TestListIdentitiesAreOwnedAndSafeForConcurrentUse(t *testing.T) {
return
}
prompts[0].ID = "worker mutation"
prompts[0].Version = "worker mutation"
if prompts[0].Version != nil {
*prompts[0].Version = "worker mutation"
}
if _, err := engine.InspectProfile(context.Background(), "profile"); err != nil {
results <- fmt.Errorf("inspect profile: %w", err)
@@ -345,7 +350,7 @@ func countListingProfile(profiles []string, id string) int {
func countListingPrompt(prompts []promptkit.PromptIdentity, id, version string) int {
count := 0
for _, prompt := range prompts {
if prompt.ID == id && prompt.Version == version {
if prompt.ID == id && prompt.Version != nil && *prompt.Version == version {
count++
}
}