From 9505f94e3d4a0a458eda491fec78722d4441bca8 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Fri, 25 Oct 2024 12:18:12 +0200 Subject: [PATCH] Refactor header test structure and improve readability Simplify test structure by renaming fields for clarity and brevity. AddressHeader tests and importance tests now use more concise and consistent naming conventions. This enhances readability and maintainability of the test code. --- header_test.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/header_test.go b/header_test.go index 02bab82..a554936 100644 --- a/header_test.go +++ b/header_test.go @@ -45,14 +45,14 @@ var ( {"Header: X-Priority", HeaderXPriority, "X-Priority"}, } addrHeaderTests = []struct { - name string - ah AddrHeader - want string + name string + header AddrHeader + want string }{ - {"Address header: From", HeaderFrom, "From"}, - {"Address header: To", HeaderTo, "To"}, - {"Address header: Cc", HeaderCc, "Cc"}, - {"Address header: Bcc", HeaderBcc, "Bcc"}, + {"From", HeaderFrom, "From"}, + {"To", HeaderTo, "To"}, + {"Cc", HeaderCc, "Cc"}, + {"Bcc", HeaderBcc, "Bcc"}, } ) @@ -64,12 +64,12 @@ func TestImportance_Stringer(t *testing.T) { xprio string want string }{ - {"Importance: Non-Urgent", ImportanceNonUrgent, "0", "5", "non-urgent"}, - {"Importance: Low", ImportanceLow, "0", "5", "low"}, - {"Importance: Normal", ImportanceNormal, "", "", ""}, - {"Importance: High", ImportanceHigh, "1", "1", "high"}, - {"Importance: Urgent", ImportanceUrgent, "1", "1", "urgent"}, - {"Importance: Unknown", 9, "", "", ""}, + {"Non-Urgent", ImportanceNonUrgent, "0", "5", "non-urgent"}, + {"Low", ImportanceLow, "0", "5", "low"}, + {"Normal", ImportanceNormal, "", "", ""}, + {"High", ImportanceHigh, "1", "1", "high"}, + {"Urgent", ImportanceUrgent, "1", "1", "urgent"}, + {"Unknown", 9, "", "", ""}, } t.Run("String", func(t *testing.T) { for _, tt := range tests { @@ -105,9 +105,9 @@ func TestImportance_Stringer(t *testing.T) { func TestAddrHeader_Stringer(t *testing.T) { for _, tt := range addrHeaderTests { t.Run(tt.name, func(t *testing.T) { - if tt.ah.String() != tt.want { + if tt.header.String() != tt.want { t.Errorf("wrong string for AddrHeader returned. Expected: %s, got: %s", - tt.want, tt.ah.String()) + tt.want, tt.header.String()) } }) }