// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
//
// SPDX-License-Identifier: LicenseRef-MutuaL-1.2

package mcp

import (
	"context"
	"strings"
	"testing"
)

// tools.READ_TOOL.7 tools.SCHEMA.3
func TestCallToolACIDToolsReadTool7ReadsExampleRecipes(t *testing.T) {
	backend := &fakeBackend{}
	server := NewServer(backend, "test")

	result, output, err := server.callReadTool(context.Background(), nil, ReadArguments{Target: "example_recipes"})
	if err != nil {
		t.Fatalf("callReadTool() error = %v", err)
	}

	text := requireTextContent(t, result)
	for _, want := range []string{
		"Title and portions are separate fields",
		"# Yudane dough improver",
		"This is a note between steps",
		"# Toast",
	} {
		if !strings.Contains(text, want) {
			t.Fatalf("example_recipes text missing %q: %q", want, text)
		}
		if !strings.Contains(output.ExampleRecipes, want) {
			t.Fatalf("example_recipes output missing %q: %q", want, output.ExampleRecipes)
		}
	}
	if backend.readShoppingListCalls != 0 || backend.page != 0 || backend.limit != 0 || backend.metadataCalls != 0 {
		t.Fatalf(
			"backend calls = shopping list %d list recipes page/limit %d/%d metadata %d, want none",
			backend.readShoppingListCalls,
			backend.page,
			backend.limit,
			backend.metadataCalls,
		)
	}
}
