//go:build test package square import "testing" func TestPaymentFromSquare_ElseBranch_SurfacesBrandWithoutCardID(t *testing.T) { p := &sqPayment{ ID: "pay_1", Status: "COMPLETED", TotalMoney: sqMoney{Amount: 5000, Currency: "GBP"}, CardDetails: &sqCardDetails{ Card: sqCard{ ID: "", CardBrand: "VISA", Last4: "4242", }, }, } result := paymentFromSquare(p) if result.CardBrand != "VISA" { t.Errorf("expected CardBrand VISA, got %s", result.CardBrand) } if result.CardLast4 != "4242" { t.Errorf("expected CardLast4 4242, got %s", result.CardLast4) } } func TestPaymentFromSquare_NilCardDetails(t *testing.T) { p := &sqPayment{ ID: "pay_2", Status: "COMPLETED", TotalMoney: sqMoney{Amount: 2500, Currency: "GBP"}, CardDetails: nil, } result := paymentFromSquare(p) if result.CardBrand != "" { t.Errorf("expected empty CardBrand when no card details, got %s", result.CardBrand) } if result.Amount != 2500 { t.Errorf("expected amount 2500, got %d", result.Amount) } }