|
@@ -0,0 +1,29 @@
|
|
|
+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.TargetURL.IsEmpty() || !su.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()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|