package domain import ( "errors" "testing" ) func TestNewShortURLHappy(t *testing.T) { tu := TargetURL{"https://example.com"} su, err := NewUnspecifiedShortURL(tu) if err != nil { t.Error(err) t.FailNow() } if su.URL.IsEmpty() || su.Target().IsEmpty() || !su.Target().MayRedirect() { t.FailNow() } } func TestNewShortURLSadFromEmpty(t *testing.T) { tu := TargetURL{""} _, err := NewUnspecifiedShortURL(tu) if err == nil { t.Error(errors.New("NewUnspecifiedShortURL should not have created ShortURL from empty target")) t.FailNow() } }