package main import ( "io/ioutil" "os" "testing" "time" "github.com/kataras/iris/v12/httptest" ) // TestURLShortener tests the simple tasks of our url shortener application. // Note that it's a pure test. // The rest possible checks is up to you, take it as as an exercise! func TestURLShortener(t *testing.T) { // temp db file f, err := ioutil.TempFile("", "shortener") if err != nil { t.Fatalf("creating temp file for database failed: %v", err) } db := NewDB(f.Name()) app := newApp(db) e := httptest.New(t, app) originalURL := "https://google.com" // save e.POST("/shorten"). WithFormField("url", originalURL).Expect(). Status(httptest.StatusOK).Body().Contains("