Repository: favonia/cloudflare-ddns
Pull request #285 (2022-11-25 03:26:32)

style: tweak error messages for misconfiguration

codecov[bot]: # [Codecov](https://codecov.io/gh/favonia/cloudflare-ddns/pull/285?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia) Report
> Merging [#285](https://codecov.io/gh/favonia/cloudflare-ddns/pull/285?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia) (9c8e399) into [main](https://codecov.io/gh/favonia/cloudflare-ddns/commit/93726ef066817515a26c26ace0b707dbd9e80093?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia) (93726ef) will **not change** coverage.
> The diff coverage is `100.00%`.

> :exclamation: Current head 9c8e399 differs from pull request most recent head 8cc2a0b. Consider uploading reports for the commit 8cc2a0b to get more accurate results

```diff
@@           Coverage Diff           @@
##             main     #285   +/-   ##
=======================================
  Coverage   86.29%   86.29%           
=======================================
  Files          28       28           
  Lines        2036     2036           
=======================================
  Hits         1757     1757           
  Misses        268      268           
  Partials       11       11           
```

| Flag | Coverage Δ | |
|---|---|---|
| unittests | `86.29% <100.00%> (ø)` | |

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=favonia#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/favonia/cloudflare-ddns/pull/285?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia) | Coverage Δ | |
|---|---|---|
| [internal/config/config.go](https://codecov.io/gh/favonia/cloudflare-ddns/pull/285/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia#diff-aW50ZXJuYWwvY29uZmlnL2NvbmZpZy5nbw==) | `98.76% <100.00%> (ø)` | |

:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia)


Patch:
diff --git a/internal/config/config.go b/internal/config/config.go
index 71f1269..09e6341 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -287,7 +287,7 @@ func (c *Config) NormalizeDomains(ppfmt pp.PP) bool {
 	}
 
 	if len(c.Domains[ipnet.IP4]) == 0 && len(c.Domains[ipnet.IP6]) == 0 {
-		ppfmt.Errorf(pp.EmojiUserError, "No domains were specified")
+		ppfmt.Errorf(pp.EmojiUserError, "No domains were specified in DOMAINS, IP4_DOMAINS, or IP6_DOMAINS")
 		return false
 	}
 
@@ -310,9 +310,10 @@ func (c *Config) NormalizeDomains(ppfmt pp.PP) bool {
 		}
 	}
 
-	// check if all policies are none
+	// check if all providers are nil
 	if providerMap[ipnet.IP4] == nil && providerMap[ipnet.IP6] == nil {
-		ppfmt.Errorf(pp.EmojiUserError, "Both IPv4 and IPv6 are disabled")
+		ppfmt.Errorf(pp.EmojiUserError, "Nothing to update because both IP4_PROVIDER and IP6_PROVIDER are %q",
+			provider.Name(nil))
 		return false
 	}
 


Test patch:
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index e8fe0c0..332cfbd 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -549,7 +549,7 @@ func TestNormalize(t *testing.T) {
 					m.EXPECT().IsEnabledFor(pp.Info).Return(true),
 					m.EXPECT().Infof(pp.EmojiEnvVars, "Checking settings . . ."),
 					m.EXPECT().IncIndent().Return(m),
-					m.EXPECT().Errorf(pp.EmojiUserError, "No domains were specified"),
+					m.EXPECT().Errorf(pp.EmojiUserError, "No domains were specified in DOMAINS, IP4_DOMAINS, or IP6_DOMAINS"),
 				)
 			},
 		},
@@ -567,7 +567,7 @@ func TestNormalize(t *testing.T) {
 					m.EXPECT().IsEnabledFor(pp.Info).Return(true),
 					m.EXPECT().Infof(pp.EmojiEnvVars, "Checking settings . . ."),
 					m.EXPECT().IncIndent().Return(m),
-					m.EXPECT().Errorf(pp.EmojiUserError, "No domains were specified"),
+					m.EXPECT().Errorf(pp.EmojiUserError, "No domains were specified in DOMAINS, IP4_DOMAINS, or IP6_DOMAINS"),
 				)
 			},
 		},
@@ -628,7 +628,9 @@ func TestNormalize(t *testing.T) {
 					m.EXPECT().Warningf(pp.EmojiUserWarning,
 						"IP%d_PROVIDER was changed to %q because no domains were set for %s",
 						6, "none", "IPv6"),
-					m.EXPECT().Errorf(pp.EmojiUserError, "Both IPv4 and IPv6 are disabled"),
+					m.EXPECT().Errorf(pp.EmojiUserError,
+						"Nothing to update because both IP4_PROVIDER and IP6_PROVIDER are %q",
+						"none"),
 				)
 			},
 		},