package storage

import (
	"os"
	"testing"

	"github.com/howznguyen/knowns/internal/models"
)

func Test{{pascalCase name}}Store(t *testing.T) {
	dir, err := os.MkdirTemp("", "{{kebabCase name}}-store-*")
	if err != nil {
		t.Fatal(err)
	}
	defer os.RemoveAll(dir)

	store := New{{pascalCase name}}Store(dir)

	t.Run("list empty", func(t *testing.T) {
		items, err := store.List()
		if err != nil {
			t.Fatal(err)
		}
		if len(items) != 0 {
			t.Errorf("expected 0 items, got %d", len(items))
		}
	})

	t.Run("create", func(t *testing.T) {
		item := models.New{{pascalCase name}}("test")
		if err := store.Create(item); err != nil {
			t.Fatal(err)
		}
	})

	t.Run("get not found", func(t *testing.T) {
		_, err := store.Get("nonexistent")
		if err == nil {
			t.Error("expected error for nonexistent ID")
		}
	})
}
