package mysql

import "testing"

func TestRuntimeAutoMigrateEnabled_DefaultsByEnvironment(t *testing.T) {
	t.Setenv(runtimeAutoMigrateEnvVar, "")

	cases := map[string]bool{
		"development": true,
		"dev":         true,
		"local":       true,
		"test":        true,
		"":            true,
		"production":  false,
		"prod":        false,
	}

	for env, want := range cases {
		if got := RuntimeAutoMigrateEnabled(env); got != want {
			t.Fatalf("RuntimeAutoMigrateEnabled(%q) = %v, want %v", env, got, want)
		}
	}
}

func TestRuntimeAutoMigrateEnabled_ExplicitOverride(t *testing.T) {
	t.Setenv(runtimeAutoMigrateEnvVar, "false")
	if RuntimeAutoMigrateEnabled("development") {
		t.Fatal("RuntimeAutoMigrateEnabled should respect explicit false override")
	}

	t.Setenv(runtimeAutoMigrateEnvVar, "true")
	if !RuntimeAutoMigrateEnabled("production") {
		t.Fatal("RuntimeAutoMigrateEnabled should respect explicit true override")
	}
}

func TestIsProductionEnvironment(t *testing.T) {
	cases := map[string]bool{
		"production": true,
		"prod":       true,
		"dev":        false,
		"":           false,
	}

	for env, want := range cases {
		if got := IsProductionEnvironment(env); got != want {
			t.Fatalf("IsProductionEnvironment(%q) = %v, want %v", env, got, want)
		}
	}
}
