package telegram import ( "testing" "time" "github.com/zelenin/go-tdlib/client" ) const testTimeFormat string = "15:03 02/01/2006" func TestOnlineStatus(t *testing.T) { show, status := userStatusToText(client.UserStatus(&client.UserStatusOnline{})) if show != "" || status != "Online" { t.Errorf("Wrong online status: %v, %v", show, status) } } func TestOnlineRecently(t *testing.T) { show, status := userStatusToText(client.UserStatus(&client.UserStatusRecently{})) if show != "dnd" || status != "Last seen recently" { t.Errorf("Wrong recently status: %v, %v", show, status) } } func TestOnlineOfflineAway(t *testing.T) { timestamp := time.Now().Unix() - 3599 time := time.Unix(timestamp, 0) show, status := userStatusToText(client.UserStatus(&client.UserStatusOffline{WasOnline: int32(timestamp)})) if show != "away" || status != "Last seen at "+time.Format(testTimeFormat) { t.Errorf("Wrong away status: %v, %v", show, status) } } func TestOnlineOfflineXa(t *testing.T) { timestamp := time.Now().Unix() - 3601 time := time.Unix(timestamp, 0) show, status := userStatusToText(client.UserStatus(&client.UserStatusOffline{WasOnline: int32(timestamp)})) if show != "xa" || status != "Last seen at "+time.Format(testTimeFormat) { t.Errorf("Wrong xa status: %v, %v", show, status) } }