|
|
package log_test
import ( "testing" "time"
"git.aiterp.net/rpdata/api/internal/store" "git.aiterp.net/rpdata/api/model/log" )
func TestMakeLogID(t *testing.T) { table := []struct { Date time.Time Channel string Expected string }{ { time.Date(2018, 4, 9, 9, 3, 0, 133000000, time.FixedZone("CEST", 7200)), "#Miner'sRespite", "2018-04-09_070300133_Miner'sRespite", }, { time.Date(2017, 3, 23, 23, 59, 59, 0, time.UTC), "#RedrockAgency", "2017-03-23_235959000_RedrockAgency", }, }
for _, row := range table { t.Run(row.Expected, func(t *testing.T) { id := log.MakeLogID(row.Date, row.Channel)
if id != row.Expected { t.Error("Failed to make ID, result:", id) } }) } }
func TestSearch(t *testing.T) { store.Init()
logs, err := log.ListSearch("", nil, []string{"C31", "C51"}, nil, false, 0) if err != nil { t.Log(err) t.Skip() }
for _, l := range logs { t.Log(l.ID) } }
func TestMovePost(t *testing.T) { store.Init()
l, err := log.FindID("L684") if err != nil { t.Log(err) t.Skip() }
posts, err := l.Posts() if err != nil { t.Log(err) t.Skip() }
for _, post := range posts { if post.ID == "blfn5uaxpyf11j4phxo" { start := time.Now()
err := post.Move(1) if err != nil { t.Error(err) }
t.Log(time.Since(start)) } } }
func TestMakePostID(t *testing.T) { t.Log(log.MakePostID(time.Now())) }
|