package server

import "testing"

func TestConvertMultipartMaxBytes_Default(t *testing.T) {
	t.Setenv("LOGPILE_CONVERT_MAX_MB", "")
	got := convertMultipartMaxBytes()
	want := int64(16384) << 20
	if got != want {
		t.Fatalf("convertMultipartMaxBytes()=%d, want %d", got, want)
	}
}

func TestConvertMultipartMaxBytes_EnvClamp(t *testing.T) {
	t.Setenv("LOGPILE_CONVERT_MAX_MB", "42")
	if got := convertMultipartMaxBytes(); got != (int64(512) << 20) {
		t.Fatalf("expected min clamp 512MB, got %d", got)
	}

	t.Setenv("LOGPILE_CONVERT_MAX_MB", "999999")
	if got := convertMultipartMaxBytes(); got != (int64(65536) << 20) {
		t.Fatalf("expected max clamp 65536MB, got %d", got)
	}

	t.Setenv("LOGPILE_CONVERT_MAX_MB", "12288")
	if got := convertMultipartMaxBytes(); got != (int64(12288) << 20) {
		t.Fatalf("expected exact env value 12288MB, got %d", got)
	}
}
