package config_center

import "testing"

func TestChangefeedEssentialConfigSupport(t *testing.T) {
	clusterType := ClusterType_CHANGEFEED_ESSENTIAL

	if clusterType != ClusterType(9) {
		t.Fatalf("expected CHANGEFEED_ESSENTIAL to use enum value 9, got %d", clusterType)
	}
	if clusterType.String() != "CHANGEFEED_ESSENTIAL" {
		t.Fatalf("unexpected cluster type string: %s", clusterType.String())
	}
	if len(clusterType.AvailableComponents()) != 0 {
		t.Fatalf("expected no components for essential changefeed")
	}
	if clusterType.DictSource() != ClusterType_CHANGEFEED {
		t.Fatalf("expected essential changefeed dict source to be CHANGEFEED")
	}

	expectedConfigTypes := ClusterType_CHANGEFEED.AvailableConfigTypes()
	actualConfigTypes := clusterType.AvailableConfigTypes()
	if len(expectedConfigTypes) != len(actualConfigTypes) {
		t.Fatalf("unexpected config type count: want %d, got %d", len(expectedConfigTypes), len(actualConfigTypes))
	}

	for i, configType := range expectedConfigTypes {
		if actualConfigTypes[i] != configType {
			t.Fatalf("unexpected config type at index %d: want %s, got %s", i, configType, actualConfigTypes[i])
		}
		if clusterType.GetConfigTypeFormat(configType) != Format_JSON {
			t.Fatalf("expected JSON format for %s", configType)
		}
	}
}
