From 8b431b5d2ffd100d8d12f727cb3105671cb3d646 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Sun, 22 Feb 2026 21:01:23 +0000 Subject: [PATCH] =?UTF-8?q?chore:=20bump=20Go=201.18=E2=86=921.26,=20fix?= =?UTF-8?q?=20typos,=20clean=20up=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update go.mod to Go 1.26 - Fix help text typos ('menut' → 'menu', 'most-significant' → 'most-specific') - Fix error comment typo ('ll' → 'all') - Remove unnecessary fmt.Sprintf in test names - Remove unused fmt imports from test files - Add compile-time interface check for TimeWindow --- go.mod | 2 +- main.go | 2 +- msp/changeover_test.go | 7 +++---- msp/errors.go | 4 ++-- msp/msp_test.go | 3 +-- msp/timeline_test.go | 2 +- msp/types.go | 3 +++ 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index d0ed8dc..b67f412 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/taigrr/most-specific-period -go 1.18 +go 1.26 diff --git a/main.go b/main.go index b0dd025..d3125b2 100644 --- a/main.go +++ b/main.go @@ -41,7 +41,7 @@ func warnMessage() { } func helpMessage() { - fmt.Print("\nmost-significant-period [-h][-d]\n\nGenerates a timeline of periods and will provide a most significant period if available.\n\n-h\tShows this help menut\n-d\tProvide a RFC 3339 time to provide an alternate point for calculating MSP.") + fmt.Print("\nmost-specific-period [-h][-d]\n\nGenerates a timeline of periods and will provide a most specific period if available.\n\n-h\tShows this help menu\n-d\tProvide an RFC 3339 time to provide an alternate point for calculating MSP.") } func main() { diff --git a/msp/changeover_test.go b/msp/changeover_test.go index cb37393..20639a5 100644 --- a/msp/changeover_test.go +++ b/msp/changeover_test.go @@ -1,7 +1,6 @@ package msp import ( - "fmt" "testing" "time" ) @@ -148,7 +147,7 @@ func TestGetChangeOvers(t *testing.T) { }, } for _, tc := range testCases { - t.Run(fmt.Sprintf("%s", tc.testID), func(t *testing.T) { + t.Run(tc.testID, func(t *testing.T) { changeovers := GetChangeOvers(tc.periods...) if !slicesEqual(changeovers, tc.result) { t.Errorf("Expected %v but got %v", tc.result, changeovers) @@ -320,7 +319,7 @@ func TestFlattenPeriods(t *testing.T) { } for _, tc := range testCases { - t.Run(fmt.Sprintf("%s", tc.testID), func(t *testing.T) { + t.Run(tc.testID, func(t *testing.T) { changeovers := FlattenPeriods(tc.periods...) if !slicesEqual(changeovers, tc.result) { t.Errorf("Expected %v but got %v", tc.result, changeovers) @@ -468,7 +467,7 @@ func TestGetNextChangeOver(t *testing.T) { }, } for _, tc := range testCases { - t.Run(fmt.Sprintf("%s", tc.testID), func(t *testing.T) { + t.Run(tc.testID, func(t *testing.T) { ts, err := GetNextChangeOver(now, tc.periods...) if tc.err != err { t.Errorf("Error %v does not match expected %v", tc.err, err) diff --git a/msp/errors.go b/msp/errors.go index 3733175..00bb5ec 100644 --- a/msp/errors.go +++ b/msp/errors.go @@ -5,9 +5,9 @@ import ( ) var ( - // ErrEndAfterStart occurs when a period given has an end time after its start time + // ErrEndAfterStart occurs when a period's start time is after its end time ErrEndAfterStart = errors.New("error: start time is after end time") - // ErrNoValidPeriods occurs when an empty set of periods is passed or when ll periods are invalid + // ErrNoValidPeriods occurs when an empty set of periods is passed or when all periods are invalid ErrNoValidPeriods = errors.New("error: no valid periods available") // ErrNoNextChangeover occurs when GetNextChangeover is called but there are no changeovers after t ErrNoNextChangeover = errors.New("error: no valid changeovers available") diff --git a/msp/msp_test.go b/msp/msp_test.go index ea66c79..be9ecef 100644 --- a/msp/msp_test.go +++ b/msp/msp_test.go @@ -1,7 +1,6 @@ package msp import ( - "fmt" "testing" "time" ) @@ -146,7 +145,7 @@ func TestMostSpecificPeriod(t *testing.T) { }, } for _, tc := range testCases { - t.Run(fmt.Sprintf("%s", tc.testID), func(t *testing.T) { + t.Run(tc.testID, func(t *testing.T) { id, err := MostSpecificPeriod(tc.ts, tc.periods...) if id != tc.result { t.Errorf("ID '%s' does not match expected '%s'", id, tc.result) diff --git a/msp/timeline_test.go b/msp/timeline_test.go index 53d9b6b..ac9bbaa 100644 --- a/msp/timeline_test.go +++ b/msp/timeline_test.go @@ -263,7 +263,7 @@ func TestGenerateTime(t *testing.T) { } for _, tc := range testCases { - t.Run(fmt.Sprintf("%s", tc.testID), func(t *testing.T) { + t.Run(tc.testID, func(t *testing.T) { timeline := GenerateTimeline(tc.periods...) if len(timeline) != len(tc.result) { t.Fatalf("Time line had %d results, expected %d", len(timeline), len(tc.result)) diff --git a/msp/types.go b/msp/types.go index f444225..6a098f3 100644 --- a/msp/types.go +++ b/msp/types.go @@ -2,6 +2,9 @@ package msp import "time" +// Compile-time interface check. +var _ Period = TimeWindow{} + type Period interface { GetStartTime() time.Time GetEndTime() time.Time