Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display $ when the currency is USD #933

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading