summaryrefslogtreecommitdiff
path: root/internal/timestamp/timestamp_test.go
blob: cdcd0e366ec4bfa1e83708b1aff52ec1512e9f6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package timestamp

import (
	"strings"
	"testing"
)

func TestUpdateInFilename(t *testing.T) {
	var (
		filePath = "gosdir/db/platforms/mastodon/1728240487.txt.20241009-232530.queued"
		nowTime  = NowTime()
	)

	updatedFilePath, err := UpdateInFilename(filePath, -2)
	if err != nil {
		t.Error(err)
	}
	parts := strings.Split(updatedFilePath, ".")

	updatedTime, err := Parse(parts[len(parts)-2])
	if err != nil {
		t.Error(err)
	}
	if nowTime.Sub(updatedTime) != 0 {
		t.Error("expected no time difference here")
	}
}