The storage system and conversion tools for the new Logs website.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.5 KiB

package main
import (
"testing"
"time"
)
func TestLogFile(t *testing.T) {
logFile := NewLogFile("./2016-12-28_201003477_#RedrockAgency.txt")
// Check Data gathered from filename
expectedTime, _ := time.Parse(time.RFC3339, "2016-12-28T20:10:03Z")
assertEqual(t, "logFile.Channel", logFile.Channel, "#RedrockAgency")
assertEqual(t, "logFile.Time", logFile.Time, expectedTime)
if t.Failed() {
return
}
// Load logfile
start := time.Now()
logFile.Load()
t.Logf("Logfile took %s to load", time.Since(start))
// Check logfile
assertEqual(t, "len(logFile.Entries)", len(logFile.Entries), 52)
assertEqual(t, "logFile.Title", logFile.Title, "Va'ynna finally speaking with Jason about the kidnapping (Skipping Work)")
assertEqual(t, "logFile.Tag", logFile.Tag, "Skipping Work")
if t.Failed() {
return
}
// Check LogEntry
expectedTime, _ = time.Parse(time.RFC3339, "2016-12-28T20:47:30Z")
entry := logFile.Entries[10]
assertEqual(t, "entry.Type", entry.Type, "ACTION")
assertEqual(t, "entry.Nick", entry.Nick, "Va`ynna_Atana")
assertEqual(t, "entry.Text", entry.Text, "looks down for a moment, a sigh escaping her. \"Mhm,\" she hums. \"That's... what I expected the moment I got the mssage from her. At least... I don't have to bother Victoria or Uvena to walk with me four trips every day, though.\"")
assertEqual(t, "entry.Time", entry.Time, expectedTime)
}
func assertEqual(t *testing.T, label string, a, b interface{}) {
if a != b {
t.Errorf("assertEquals (%s): \n\tGot: %+v\n\tExpected: %+v", label, a, b)
t.Fail()
}
}