Repository: hetznercloud/cli
Pull request #933 (2024-12-09 09:41:45)

fix: display $ when the currency is USD
Display a dollar sign when the currency is USD.

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/hetznercloud/cli/pull/933?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hetznercloud) Report
Attention: Patch coverage is `0%` with `2 lines` in your changes missing coverage. Please review.
> Project coverage is 63.47%. Comparing base [(`adf4e9e`)](https://app.codecov.io/gh/hetznercloud/cli/commit/adf4e9e5b44570cbb4278d74f59e951e636fea90?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hetznercloud) to head [(`7ffdff5`)](https://app.codecov.io/gh/hetznercloud/cli/commit/7ffdff5d95828131e8b92c4563b0bb2c4eb69a77?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hetznercloud).

| [Files with missing lines](https://app.codecov.io/gh/hetznercloud/cli/pull/933?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hetznercloud) | Patch % | Lines |
|---|---|---|
| [internal/cmd/util/util.go](https://app.codecov.io/gh/hetznercloud/cli/pull/933?src=pr&el=tree&filepath=internal%2Fcmd%2Futil%2Futil.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hetznercloud#diff-aW50ZXJuYWwvY21kL3V0aWwvdXRpbC5nbw==) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/hetznercloud/cli/pull/933?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hetznercloud) |

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main     #933      +/-   ##
==========================================
- Coverage   69.23%   63.47%   -5.77%     
==========================================
  Files         244      243       -1     
  Lines       10640    10637       -3     
==========================================
- Hits         7367     6752     -615     
- Misses       2605     3172     +567     
- Partials      668      713      +45     
```

| [Flag](https://app.codecov.io/gh/hetznercloud/cli/pull/933/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hetznercloud) | Coverage Δ | |
|---|---|---|
| [e2e](https://app.codecov.io/gh/hetznercloud/cli/pull/933/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hetznercloud) | `?` | |
| [unit](https://app.codecov.io/gh/hetznercloud/cli/pull/933/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hetznercloud) | `63.47% <0.00%> (-0.02%)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hetznercloud#carryforward-flags-in-the-pull-request-comment) to find out more.

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/hetznercloud/cli/pull/933?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hetznercloud).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=hetznercloud).


Patch:
diff --git a/internal/cmd/util/util.go b/internal/cmd/util/util.go
index 6414863..cad51ea 100644
--- a/internal/cmd/util/util.go
+++ b/internal/cmd/util/util.go
@@ -67,6 +67,8 @@ func GrossPrice(price hcloud.Price) string {
 	switch price.Currency {
 	case "EUR":
 		currencyDisplay = "€"
+	case "USD":
+		currencyDisplay = "$"
 	default:
 		// unchanged
 	}


Test patch:
diff --git a/internal/cmd/util/util_test.go b/internal/cmd/util/util_test.go
index 6b407fe..833e04d 100644
--- a/internal/cmd/util/util_test.go
+++ b/internal/cmd/util/util_test.go
@@ -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"},