Skip to content

Commit

Permalink
fix: display $ when the currency is USD (#933)
Browse files Browse the repository at this point in the history
Display a dollar sign when the currency is USD.

---------

Co-authored-by: Julian Tölle <[email protected]>
  • Loading branch information
jooola and apricote authored Dec 10, 2024
1 parent dbcf45d commit 0d1f5e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions internal/cmd/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func GrossPrice(price hcloud.Price) string {
switch price.Currency {
case "EUR":
currencyDisplay = "€"
case "USD":
currencyDisplay = "$"
default:
// unchanged
}
Expand Down
7 changes: 6 additions & 1 deletion internal/cmd/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,15 @@ func TestPrice(t *testing.T) {
want string
}{
{
name: "known currency",
name: "known currency (EUR)",
price: hcloud.Price{Currency: "EUR", Gross: "5.00"},
want: "€\u00a05.00",
},
{
name: "known currency (USD)",
price: hcloud.Price{Currency: "USD", Gross: "5.00"},
want: "$\u00a05.00",
},
{
name: "unknown currency",
price: hcloud.Price{Currency: "HOL", Gross: "1.2"},
Expand Down

0 comments on commit 0d1f5e9

Please sign in to comment.