Repository: favonia/cloudflare-ddns
Pull request #825 (2024-07-22 11:57:01)

refactor(pp): reorganize emojis for the WAF PR

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/favonia/cloudflare-ddns/pull/825?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 93.90%. Comparing base [(`13dd552`)](https://app.codecov.io/gh/favonia/cloudflare-ddns/commit/13dd5529b2d944bbcbbc26c68747dc02e511c506?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia) to head [(`869dbf1`)](https://app.codecov.io/gh/favonia/cloudflare-ddns/commit/869dbf155217f264ce711ce79c181a074df0cdfd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia).

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


```diff
@@           Coverage Diff           @@
##             main     #825   +/-   ##
=======================================
  Coverage   93.90%   93.90%           
=======================================
  Files          54       54           
  Lines        2200     2200           
=======================================
  Hits         2066     2066           
  Misses        121      121           
  Partials       13       13           
```

| [Flag](https://app.codecov.io/gh/favonia/cloudflare-ddns/pull/825/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia) | Coverage Δ | |
|---|---|---|
| [unittests](https://app.codecov.io/gh/favonia/cloudflare-ddns/pull/825/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia) | `93.90% <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.

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/favonia/cloudflare-ddns/pull/825?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia).   
: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=favonia).


Patch:
diff --git a/internal/pp/emoji.go b/internal/pp/emoji.go
index 33a00de..80ae46e 100644
--- a/internal/pp/emoji.go
+++ b/internal/pp/emoji.go
@@ -15,17 +15,17 @@ const (
 	EmojiDisabled     Emoji = "🚫" // feature is disabled
 	EmojiExperimental Emoji = "🧪" // experimental features
 
-	EmojiCreateRecord Emoji = "🐣" // adding new DNS records
-	EmojiDeleteRecord Emoji = "💀" // deleting DNS records
-	EmojiUpdateRecord Emoji = "📡" // updating DNS records
-	EmojiClearRecord  Emoji = "🧹" // clearing DNS records when exiting
-	EmojiBailingOut   Emoji = "💨" // bailing out
+	EmojiCreation Emoji = "🐣" // adding new DNS records
+	EmojiDeletion Emoji = "💀" // deleting DNS records
+	EmojiUpdate   Emoji = "📡" // updating DNS records
+	EmojiClear    Emoji = "🧹" // clearing DNS records when exiting
 
 	EmojiPing    Emoji = "🔔" // pinging and health checks
 	EmojiMessage Emoji = "📨" // notifications
 
 	EmojiSignal      Emoji = "🚨" // catching signals
 	EmojiAlreadyDone Emoji = "🤷" // DNS records were already up to date
+	EmojiBailingOut  Emoji = "💨" // bailing out
 	EmojiNow         Emoji = "🏃" // an event that is happening now or immediately
 	EmojiAlarm       Emoji = "⏰" // an event that is scheduled to happen, but not immediately
 	EmojiBye         Emoji = "👋" // bye!
diff --git a/internal/setter/setter.go b/internal/setter/setter.go
index 1c5bfcb..3a14348 100644
--- a/internal/setter/setter.go
+++ b/internal/setter/setter.go
@@ -116,7 +116,7 @@ func (s setter) Set(ctx context.Context, ppfmt pp.PP,
 				// If the updating succeeds, we can move on to the next stage!
 				//
 				// Note that there can still be stale records at this point.
-				ppfmt.Noticef(pp.EmojiUpdateRecord,
+				ppfmt.Noticef(pp.EmojiUpdate,
 					"Updated a stale %s record of %q (ID: %q)",
 					recordType, domainDescription, id)
 
@@ -134,7 +134,7 @@ func (s setter) Set(ctx context.Context, ppfmt pp.PP,
 
 			// If the updating fails, we will delete it.
 			if s.Handle.DeleteRecord(ctx, ppfmt, domain, ipnet, id) {
-				ppfmt.Noticef(pp.EmojiDeleteRecord,
+				ppfmt.Noticef(pp.EmojiDeletion,
 					"Deleted a stale %s record of %q (ID: %q)",
 					recordType, domainDescription, id)
 
@@ -155,7 +155,7 @@ func (s setter) Set(ctx context.Context, ppfmt pp.PP,
 	if !foundMatched {
 		if id, ok := s.Handle.CreateRecord(ctx, ppfmt,
 			domain, ipnet, ip, ttl, proxied, recordComment); ok {
-			ppfmt.Noticef(pp.EmojiCreateRecord,
+			ppfmt.Noticef(pp.EmojiCreation,
 				"Added a new %s record of %q (ID: %q)",
 				recordType, domainDescription, id)
 
@@ -170,7 +170,7 @@ func (s setter) Set(ctx context.Context, ppfmt pp.PP,
 	// Now, we should try to delete all remaining stale records.
 	for _, id := range unprocessedUnmatched {
 		if s.Handle.DeleteRecord(ctx, ppfmt, domain, ipnet, id) {
-			ppfmt.Noticef(pp.EmojiDeleteRecord,
+			ppfmt.Noticef(pp.EmojiDeletion,
 				"Deleted a stale %s record of %q (ID: %q)",
 				recordType, domainDescription, id)
 			numUndeletedUnmatched--
@@ -183,7 +183,7 @@ func (s setter) Set(ctx context.Context, ppfmt pp.PP,
 	// This has lower priority than deleting the stale records.
 	for _, id := range unprocessedMatched {
 		if s.Handle.DeleteRecord(ctx, ppfmt, domain, ipnet, id) {
-			ppfmt.Noticef(pp.EmojiDeleteRecord,
+			ppfmt.Noticef(pp.EmojiDeletion,
 				"Deleted a duplicate %s record of %q (ID: %q)",
 				recordType, domainDescription, id)
 		} else if ctx.Err() != nil {
@@ -244,7 +244,7 @@ func (s setter) Delete(ctx context.Context, ppfmt pp.PP, domain domain.Domain, i
 			continue
 		}
 
-		ppfmt.Noticef(pp.EmojiDeleteRecord, "Deleted a stale %s record of %q (ID: %q)", recordType, domainDescription, id)
+		ppfmt.Noticef(pp.EmojiDeletion, "Deleted a stale %s record of %q (ID: %q)", recordType, domainDescription, id)
 	}
 	if !allOk {
 		ppfmt.Errorf(pp.EmojiError,


Test patch:
diff --git a/internal/setter/setter_test.go b/internal/setter/setter_test.go
index fe1af2e..9e73c20 100644
--- a/internal/setter/setter_test.go
+++ b/internal/setter/setter_test.go
@@ -94,7 +94,7 @@ func TestSet(t *testing.T) {
 				gomock.InOrder(
 					h.EXPECT().ListRecords(ctx, p, domain, ipNetwork).Return(map[string]netip.Addr{}, true, true),
 					h.EXPECT().CreateRecord(ctx, p, domain, ipNetwork, ip1, api.TTLAuto, false, "hello").Return(record1, true),
-					p.EXPECT().Noticef(pp.EmojiCreateRecord, "Added a new %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1),
+					p.EXPECT().Noticef(pp.EmojiCreation, "Added a new %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1),
 				)
 			},
 		},
@@ -105,7 +105,7 @@ func TestSet(t *testing.T) {
 				gomock.InOrder(
 					h.EXPECT().ListRecords(ctx, p, domain, ipNetwork).Return(map[string]netip.Addr{record1: ip2}, true, true),
 					h.EXPECT().UpdateRecord(ctx, p, domain, ipNetwork, record1, ip1).Return(true),
-					p.EXPECT().Noticef(pp.EmojiUpdateRecord,
+					p.EXPECT().Noticef(pp.EmojiUpdate,
 						"Updated a stale %s record of %q (ID: %q)",
 						"AAAA",
 						"sub.test.org",
@@ -122,9 +122,9 @@ func TestSet(t *testing.T) {
 					h.EXPECT().ListRecords(ctx, p, domain, ipNetwork).Return(map[string]netip.Addr{record1: ip2}, true, true),
 					h.EXPECT().UpdateRecord(ctx, p, domain, ipNetwork, record1, ip1).Return(false),
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record1).Return(true),
-					p.EXPECT().Noticef(pp.EmojiDeleteRecord, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1), //nolint:lll
+					p.EXPECT().Noticef(pp.EmojiDeletion, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1), //nolint:lll
 					h.EXPECT().CreateRecord(ctx, p, domain, ipNetwork, ip1, api.TTLAuto, false, "hello").Return(record2, true),
-					p.EXPECT().Noticef(pp.EmojiCreateRecord, "Added a new %s record of %q (ID: %q)", "AAAA", "sub.test.org", record2),
+					p.EXPECT().Noticef(pp.EmojiCreation, "Added a new %s record of %q (ID: %q)", "AAAA", "sub.test.org", record2),
 				)
 			},
 		},
@@ -186,7 +186,7 @@ func TestSet(t *testing.T) {
 						Return(map[string]netip.Addr{record1: ip1, record2: ip1}, true, true),
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record2).Return(true),
 					p.EXPECT().Noticef(
-						pp.EmojiDeleteRecord,
+						pp.EmojiDeletion,
 						"Deleted a duplicate %s record of %q (ID: %q)",
 						"AAAA",
 						"sub.test.org",
@@ -228,14 +228,14 @@ func TestSet(t *testing.T) {
 						Return(map[string]netip.Addr{record1: ip2, record2: ip2}, true, true),
 					h.EXPECT().UpdateRecord(ctx, p, domain, ipNetwork, record1, ip1).Return(true),
 					p.EXPECT().Noticef(
-						pp.EmojiUpdateRecord,
+						pp.EmojiUpdate,
 						"Updated a stale %s record of %q (ID: %q)",
 						"AAAA",
 						"sub.test.org",
 						record1,
 					),
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record2).Return(true),
-					p.EXPECT().Noticef(pp.EmojiDeleteRecord,
+					p.EXPECT().Noticef(pp.EmojiDeletion,
 						"Deleted a stale %s record of %q (ID: %q)",
 						"AAAA",
 						"sub.test.org",
@@ -252,7 +252,7 @@ func TestSet(t *testing.T) {
 						Return(map[string]netip.Addr{record1: ip2, record2: ip2}, true, true),
 					h.EXPECT().UpdateRecord(ctx, p, domain, ipNetwork, record1, ip1).Return(true),
 					p.EXPECT().Noticef(
-						pp.EmojiUpdateRecord,
+						pp.EmojiUpdate,
 						"Updated a stale %s record of %q (ID: %q)",
 						"AAAA",
 						"sub.test.org",
@@ -274,14 +274,14 @@ func TestSet(t *testing.T) {
 					h.EXPECT().UpdateRecord(ctx, p, domain, ipNetwork, record1, ip1).Return(false),
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record1).Return(true),
 					p.EXPECT().Noticef(
-						pp.EmojiDeleteRecord,
+						pp.EmojiDeletion,
 						"Deleted a stale %s record of %q (ID: %q)",
 						"AAAA",
 						"sub.test.org",
 						record1),
 					h.EXPECT().UpdateRecord(ctx, p, domain, ipNetwork, record2, ip1).Return(true),
 					p.EXPECT().Noticef(
-						pp.EmojiUpdateRecord,
+						pp.EmojiUpdate,
 						"Updated a stale %s record of %q (ID: %q)",
 						"AAAA",
 						"sub.test.org",
@@ -299,12 +299,12 @@ func TestSet(t *testing.T) {
 						Return(map[string]netip.Addr{record1: ip2, record2: ip2}, true, true),
 					h.EXPECT().UpdateRecord(ctx, p, domain, ipNetwork, record1, ip1).Return(false),
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record1).Return(true),
-					p.EXPECT().Noticef(pp.EmojiDeleteRecord, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1), //nolint:lll
+					p.EXPECT().Noticef(pp.EmojiDeletion, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1), //nolint:lll
 					h.EXPECT().UpdateRecord(ctx, p, domain, ipNetwork, record2, ip1).Return(false),
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record2).Return(true),
-					p.EXPECT().Noticef(pp.EmojiDeleteRecord, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record2), //nolint:lll
+					p.EXPECT().Noticef(pp.EmojiDeletion, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record2), //nolint:lll
 					h.EXPECT().CreateRecord(ctx, p, domain, ipNetwork, ip1, api.TTLAuto, false, "hello").Return(record3, true),
-					p.EXPECT().Noticef(pp.EmojiCreateRecord, "Added a new %s record of %q (ID: %q)", "AAAA", "sub.test.org", record3),
+					p.EXPECT().Noticef(pp.EmojiCreation, "Added a new %s record of %q (ID: %q)", "AAAA", "sub.test.org", record3),
 				)
 			},
 		},
@@ -318,9 +318,9 @@ func TestSet(t *testing.T) {
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record1).Return(false),
 					h.EXPECT().UpdateRecord(ctx, p, domain, ipNetwork, record2, ip1).Return(false),
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record2).Return(true),
-					p.EXPECT().Noticef(pp.EmojiDeleteRecord, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record2), //nolint:lll
+					p.EXPECT().Noticef(pp.EmojiDeletion, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record2), //nolint:lll
 					h.EXPECT().CreateRecord(ctx, p, domain, ipNetwork, ip1, api.TTLAuto, false, "hello").Return(record3, true),
-					p.EXPECT().Noticef(pp.EmojiCreateRecord, "Added a new %s record of %q (ID: %q)", "AAAA", "sub.test.org", record3),                     //nolint:lll
+					p.EXPECT().Noticef(pp.EmojiCreation, "Added a new %s record of %q (ID: %q)", "AAAA", "sub.test.org", record3),                         //nolint:lll
 					p.EXPECT().Errorf(pp.EmojiError, "Failed to finish updating %s records of %q; records might be inconsistent", "AAAA", "sub.test.org"), //nolint:lll
 				)
 			},
@@ -333,10 +333,10 @@ func TestSet(t *testing.T) {
 					h.EXPECT().ListRecords(ctx, p, domain, ipNetwork).Return(map[string]netip.Addr{record1: ip2, record2: ip2}, true, true), //nolint:lll
 					h.EXPECT().UpdateRecord(ctx, p, domain, ipNetwork, record1, ip1).Return(false),
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record1).Return(true),
-					p.EXPECT().Noticef(pp.EmojiDeleteRecord, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1), //nolint:lll
+					p.EXPECT().Noticef(pp.EmojiDeletion, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1), //nolint:lll
 					h.EXPECT().UpdateRecord(ctx, p, domain, ipNetwork, record2, ip1).Return(false),
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record2).Return(true),
-					p.EXPECT().Noticef(pp.EmojiDeleteRecord, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record2), //nolint:lll
+					p.EXPECT().Noticef(pp.EmojiDeletion, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record2), //nolint:lll
 					h.EXPECT().CreateRecord(ctx, p, domain, ipNetwork, ip1, api.TTLAuto, false, "hello").Return(record3, false),
 					p.EXPECT().Errorf(pp.EmojiError, "Failed to finish updating %s records of %q; records might be inconsistent", "AAAA", "sub.test.org"), //nolint:lll
 				)
@@ -351,10 +351,10 @@ func TestSet(t *testing.T) {
 						Return(map[string]netip.Addr{record1: ip2, record2: ip2}, true, true),
 					h.EXPECT().UpdateRecord(ctx, p, domain, ipNetwork, record1, ip1).Return(false),
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record1).Return(true),
-					p.EXPECT().Noticef(pp.EmojiDeleteRecord, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1), //nolint:lll
+					p.EXPECT().Noticef(pp.EmojiDeletion, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1), //nolint:lll
 					h.EXPECT().UpdateRecord(ctx, p, domain, ipNetwork, record2, ip1).Return(false),
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record2).Return(true),
-					p.EXPECT().Noticef(pp.EmojiDeleteRecord, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record2), //nolint:lll
+					p.EXPECT().Noticef(pp.EmojiDeletion, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record2), //nolint:lll
 					h.EXPECT().CreateRecord(ctx, p, domain, ipNetwork, ip1, api.TTLAuto, false, "hello").
 						Do(wrapCancelAsCreate(cancel)).Return(record3, false),
 					p.EXPECT().Infof(pp.EmojiBailingOut, "Operation aborted (%v); bailing out . . .", gomock.Any()),
@@ -435,7 +435,7 @@ func TestDelete(t *testing.T) {
 				gomock.InOrder(
 					h.EXPECT().ListRecords(ctx, p, domain, ipNetwork).Return(map[string]netip.Addr{record1: ip1}, true, true),
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record1).Return(true),
-					p.EXPECT().Noticef(pp.EmojiDeleteRecord, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1), //nolint:lll
+					p.EXPECT().Noticef(pp.EmojiDeletion, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1), //nolint:lll
 				)
 			},
 		},
@@ -467,9 +467,9 @@ func TestDelete(t *testing.T) {
 				gomock.InOrder(
 					h.EXPECT().ListRecords(ctx, p, domain, ipNetwork).Return(map[string]netip.Addr{record1: ip1, record2: invalidIP}, true, true), //nolint:lll
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record1).Return(true),
-					p.EXPECT().Noticef(pp.EmojiDeleteRecord, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1), //nolint:lll
+					p.EXPECT().Noticef(pp.EmojiDeletion, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record1), //nolint:lll
 					h.EXPECT().DeleteRecord(ctx, p, domain, ipNetwork, record2).Return(true),
-					p.EXPECT().Noticef(pp.EmojiDeleteRecord, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record2), //nolint:lll
+					p.EXPECT().Noticef(pp.EmojiDeletion, "Deleted a stale %s record of %q (ID: %q)", "AAAA", "sub.test.org", record2), //nolint:lll
 				)
 			},
 		},