package facts

import (
	"os"
	"path/filepath"
	"testing"
)

func TestLoadDirReadsSnapshots(t *testing.T) {
	dir := t.TempDir()
	snap := `{"hostname":"n1","kernel":"k","containerd":"c","package_sample":{"a":"1"}}`
	if err := os.WriteFile(filepath.Join(dir, "snap.json"), []byte(snap), 0o644); err != nil {
		t.Fatal(err)
	}
	got, err := LoadDir(dir)
	if err != nil {
		t.Fatalf("LoadDir: %v", err)
	}
	if len(got) != 1 || got[0].Hostname != "n1" || got[0].PackageSample["a"] != "1" {
		t.Fatalf("unexpected snapshot: %+v", got)
	}
}
