package config

import "testing"

func TestCapacityPoolsAreDataDriven(t *testing.T) {
	cfg := Config{CapacityPoolsJSON: `[
		{"id":"pool-a","adapterRef":"deployment-a","bootstrapReplicas":1,"minReplicas":1,"maxReplicas":3},
		{"id":"pool-b","adapterRef":"deployment-b","bootstrapReplicas":0,"minReplicas":0,"maxReplicas":2}
	]`}
	pools, err := cfg.CapacityPools()
	if err != nil {
		t.Fatal(err)
	}
	if len(pools) != 2 || pools[0].ID != "pool-a" || pools[1].AdapterRef != "deployment-b" {
		t.Fatalf("pools=%+v", pools)
	}
}

func TestCapacityPoolsRejectDuplicates(t *testing.T) {
	cfg := Config{CapacityPoolsJSON: `[
		{"id":"pool-a","bootstrapReplicas":1,"minReplicas":1,"maxReplicas":1},
		{"id":"pool-a","bootstrapReplicas":1,"minReplicas":1,"maxReplicas":1}
	]`}
	if _, err := cfg.CapacityPools(); err == nil {
		t.Fatal("expected duplicate pool rejection")
	}
}
