From 8d1fd1f5e0b77707199c6e22b028b27126125e55 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 14 Oct 2024 23:33:58 +0300 Subject: fix timestamp --- internal/timestamp/timestamp.go | 4 ++-- internal/timestamp/timestamp_test.go | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'internal/timestamp') diff --git a/internal/timestamp/timestamp.go b/internal/timestamp/timestamp.go index 8c048df..425bc2f 100644 --- a/internal/timestamp/timestamp.go +++ b/internal/timestamp/timestamp.go @@ -36,6 +36,6 @@ func OldestValidTime() time.Time { func UpdateInFilename(filename string, rIndex int) string { parts := strings.Split(filename, ".") - parts[len(parts)-rIndex] = Now() - return strings.Join(parts, "-") + parts[len(parts)+rIndex] = Now() + return strings.Join(parts, ".") } diff --git a/internal/timestamp/timestamp_test.go b/internal/timestamp/timestamp_test.go index 27d0fd4..499d7d5 100644 --- a/internal/timestamp/timestamp_test.go +++ b/internal/timestamp/timestamp_test.go @@ -3,13 +3,14 @@ package timestamp import ( "strings" "testing" - "time" ) func TestUpdateInFilename(t *testing.T) { + t.Parallel() + var ( filePath = "gosdir/db/platforms/mastodon/1728240487.txt.20241009-232530.queued" - nowTime = time.Now() + nowTime = NowTime() updatedFilePath = UpdateInFilename(filePath, -2) parts = strings.Split(updatedFilePath, ".") ) @@ -18,6 +19,7 @@ func TestUpdateInFilename(t *testing.T) { if err != nil { t.Error(err) } - - t.Log(filePath, updatedFilePath, nowTime.Sub(updatedTime)) + if nowTime.Sub(updatedTime) != 0 { + t.Error("expected no time difference here") + } } -- cgit v1.2.3