ssh-chat/humantime_test.go
Andrey Petrov 66fee99a81 /uptime and /whois relative timestamps made more precise
Replaced go-humanize dependency with our own logic.

Fixes #259.
2018-01-19 12:35:45 -05:00

41 lines
563 B
Go

package sshchat
import (
"testing"
"time"
)
func TestHumanSince(t *testing.T) {
tests := []struct {
input time.Duration
expected string
}{
{
time.Second * 42,
"42 seconds",
},
{
time.Second * 60 * 5,
"5 minutes",
},
{
time.Hour * 3,
"3 hours",
},
{
time.Hour * 49,
"2 days",
},
{
time.Hour * 24 * 900,
"900 days",
},
}
for _, test := range tests {
if actual, expected := humanSince(test.input), test.expected; actual != expected {
t.Errorf("Got: %q; Expected: %q", actual, expected)
}
}
}