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

  1. package main
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. func TestLogFile(t *testing.T) {
  7. logFile := NewLogFile("./2016-12-28_201003477_#RedrockAgency.txt")
  8. // Check Data gathered from filename
  9. expectedTime, _ := time.Parse(time.RFC3339, "2016-12-28T20:10:03Z")
  10. assertEqual(t, "logFile.Channel", logFile.Channel, "#RedrockAgency")
  11. assertEqual(t, "logFile.Time", logFile.Time, expectedTime)
  12. if t.Failed() {
  13. return
  14. }
  15. // Load logfile
  16. start := time.Now()
  17. logFile.Load()
  18. t.Logf("Logfile took %s to load", time.Since(start))
  19. // Check logfile
  20. assertEqual(t, "len(logFile.Entries)", len(logFile.Entries), 52)
  21. assertEqual(t, "logFile.Title", logFile.Title, "Va'ynna finally speaking with Jason about the kidnapping (Skipping Work)")
  22. assertEqual(t, "logFile.Tag", logFile.Tag, "Skipping Work")
  23. if t.Failed() {
  24. return
  25. }
  26. // Check LogEntry
  27. expectedTime, _ = time.Parse(time.RFC3339, "2016-12-28T20:47:30Z")
  28. entry := logFile.Entries[10]
  29. assertEqual(t, "entry.Type", entry.Type, "ACTION")
  30. assertEqual(t, "entry.Nick", entry.Nick, "Va`ynna_Atana")
  31. 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.\"")
  32. assertEqual(t, "entry.Time", entry.Time, expectedTime)
  33. }
  34. func assertEqual(t *testing.T, label string, a, b interface{}) {
  35. if a != b {
  36. t.Errorf("assertEquals (%s): \n\tGot: %+v\n\tExpected: %+v", label, a, b)
  37. t.Fail()
  38. }
  39. }