69 lines
1.3 KiB
Go
69 lines
1.3 KiB
Go
package github_test
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
var (
|
|
gh github.Github = github.Github{}
|
|
)
|
|
|
|
func TestName(t *testing.T) {
|
|
want := "Twitter"
|
|
got := tw.String()
|
|
|
|
if got != want {
|
|
t.Errorf("twitter.Name() = %s; want %s", got, want)
|
|
}
|
|
|
|
}
|
|
func TestUsernameTooShort(t *testing.T) {
|
|
username := ""
|
|
want := false
|
|
got := tw.IsValid(username)
|
|
|
|
if got != want {
|
|
t.Errorf("twitter.IsValid(%s) = %t; want %t", username, got, want)
|
|
}
|
|
}
|
|
func TestUsernameTooLong(t *testing.T) {
|
|
username := "azetrgdkalakdzjazdzaidadhazdazidazdazmdazldkazda"
|
|
want := false
|
|
got := tw.IsValid(username)
|
|
|
|
if got != want {
|
|
t.Errorf("twitter.IsValid(%s) = %t; want %t", username, got, want)
|
|
}
|
|
}
|
|
func TestUsernameContainsIllegalPattern(t *testing.T) {
|
|
username := "psetwiTterdo"
|
|
want := false
|
|
got := tw.IsValid(username)
|
|
|
|
if got != want {
|
|
t.Errorf("twitter.IsValid(%s) = %t; want %t", username, got, want)
|
|
}
|
|
}
|
|
func TestUsernameContainsNotOnlyLegalPattern(t *testing.T) {
|
|
username := "pseudo-"
|
|
want := false
|
|
got := tw.IsValid(username)
|
|
|
|
if got != want {
|
|
t.Errorf("twitter.IsValid(%s) = %t; want %t", username, got, want)
|
|
}
|
|
}
|
|
func TestUsernameAvailablePattern(t *testing.T) {
|
|
username := "jubobs"
|
|
want := false
|
|
got, err := tw.IsAvailable(username)
|
|
|
|
if err != nil {
|
|
t.Errorf("%v", err)
|
|
}
|
|
|
|
if got != want {
|
|
t.Errorf("twitter.IsValid(%s) = %t; want %t", username, got, want)
|
|
}
|
|
}
|