diff options
| author | Paul Buetow <paul@buetow.org> | 2024-10-14 23:33:58 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-10-14 23:33:58 +0300 |
| commit | 8d1fd1f5e0b77707199c6e22b028b27126125e55 (patch) | |
| tree | b698d7e06048518f805631d5fdc53f46da8c1641 /internal/timestamp | |
| parent | 319cb31fd5fc5b86eb46e2090fb45425243b908c (diff) | |
fix timestamp
Diffstat (limited to 'internal/timestamp')
| -rw-r--r-- | internal/timestamp/timestamp.go | 4 | ||||
| -rw-r--r-- | internal/timestamp/timestamp_test.go | 10 |
2 files changed, 8 insertions, 6 deletions
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") + } } |
