util_test.go 510 B

123456789101112131415161718192021
  1. package discordgo
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. func TestSnowflakeTimestamp(t *testing.T) {
  7. // #discordgo channel ID :)
  8. id := "155361364909621248"
  9. parsedTimestamp, err := SnowflakeTimestamp(id)
  10. if err != nil {
  11. t.Errorf("returned error incorrect: got %v, want nil", err)
  12. }
  13. correctTimestamp := time.Date(2016, time.March, 4, 17, 10, 35, 869*1000000, time.UTC)
  14. if !parsedTimestamp.Equal(correctTimestamp) {
  15. t.Errorf("parsed time incorrect: got %v, want %v", parsedTimestamp, correctTimestamp)
  16. }
  17. }