shopping_list_add_test.go

 1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
 2//
 3// SPDX-License-Identifier: LicenseRef-MutuaL-1.2
 4
 5package mcp
 6
 7import (
 8	"context"
 9	"testing"
10
11	"git.secluded.site/cooked-mcp/internal/cooked"
12)
13
14func TestCallToolACIDShoppingListAdd5NormalizesReadOutputQuantity(t *testing.T) {
15	backend := &fakeBackend{addShoppingListResult: cooked.AddShoppingListResult{
16		AddedCount:  2,
17		Ingredients: []string{"1 Tool selection test item", "1 zz tool selection test"},
18	}}
19	server := NewServer(backend, "test")
20
21	_, _, err := server.callChangeShoppingListTool(
22		context.Background(),
23		nil,
24		ChangeShoppingListArguments{
25			Action:      "add",
26			Ingredients: "Tool selection test item — 1\n1 zz tool selection test",
27		},
28	)
29	if err != nil {
30		t.Fatalf("callChangeShoppingListTool() error = %v", err)
31	}
32
33	if backend.addIngredients != "1 Tool selection test item\n1 zz tool selection test" {
34		t.Fatalf("backend ingredients = %q, want normalized ingredients", backend.addIngredients)
35	}
36}