package dto

import "testing"

func TestRegisterRequestNormalizeUsesSnakeCaseAlternates(t *testing.T) {
	active := false
	mustChange := true
	req := RegisterRequest{
		WorkspaceIDSnake:        "workspace-1",
		DefaultClusterIDSnake:   "cluster-1",
		QuotaCPUSnake:           "2",
		QuotaMemorySnake:        "4Gi",
		QuotaGPUSnake:           "1",
		QuotaGPUMemSnake:        "10000",
		IsActiveSnake:           &active,
		MustChangePasswordSnake: &mustChange,
	}

	req.Normalize()

	if req.WorkspaceID != "workspace-1" || req.DefaultClusterID != "cluster-1" {
		t.Fatalf("expected snake case workspace/cluster fields to normalize, got %#v", req)
	}
	if req.QuotaCPU != "2" || req.QuotaMemory != "4Gi" || req.QuotaGPU != "1" || req.QuotaGPUMem != "10000" {
		t.Fatalf("expected snake case quota fields to normalize, got %#v", req)
	}
	if req.IsActive == nil || *req.IsActive {
		t.Fatalf("expected is_active=false to normalize, got %#v", req.IsActive)
	}
	if req.MustChangePassword == nil || !*req.MustChangePassword {
		t.Fatalf("expected must_change_password=true to normalize, got %#v", req.MustChangePassword)
	}
}

func TestUpdateUserRequestNormalizeKeepsCamelCasePrimary(t *testing.T) {
	req := UpdateUserRequest{
		DefaultClusterID:      "camel-cluster",
		DefaultClusterIDSnake: "snake-cluster",
		QuotaCPU:              "3",
		QuotaCPUSnake:         "4",
	}

	req.Normalize()

	if req.DefaultClusterID != "camel-cluster" {
		t.Fatalf("expected camelCase defaultClusterId to win, got %q", req.DefaultClusterID)
	}
	if req.QuotaCPU != "3" {
		t.Fatalf("expected camelCase quotaCpu to win, got %q", req.QuotaCPU)
	}
}
