package grpc

import (
	"testing"

	walletv1 "hyapp.local/api/proto/wallet/v1"
)

func TestResourceCommandDefaultsManagerGrantDisabled(t *testing.T) {
	command := resourceCommandFromCreate(&walletv1.CreateResourceRequest{
		ResourceCode: "badge_default_manager_disabled",
		ResourceType: "badge",
		Name:         "Default Manager Disabled Badge",
		Status:       "active",
		Grantable:    true,
	})

	if command.ManagerGrantEnabled {
		t.Fatalf("manager grant should default to disabled")
	}
}

func TestResourceCommandKeepsExplicitManagerGrantEnabled(t *testing.T) {
	enabled := true
	command := resourceCommandFromCreate(&walletv1.CreateResourceRequest{
		ResourceCode:        "badge_manager_enabled",
		ResourceType:        "badge",
		Name:                "Manager Enabled Badge",
		Status:              "active",
		Grantable:           true,
		ManagerGrantEnabled: &enabled,
	})

	if !command.ManagerGrantEnabled {
		t.Fatalf("explicit manager grant enabled should be preserved")
	}
}
