package imgscale

import (
	"github.com/stretchr/testify/assert"
	"testing"
	"net/http"
	"net/http/httptest"
)

func TestHttpFetchOK(t *testing.T) {
	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, "../data/kth.jpg")
	}))
	defer ts.Close()
	
	provider := NewImageProviderHTTP("")
	img, err := provider.Fetch(ts.URL)
	defer img.Destroy()
	
	assert.Nil(t, err)
	assert.Equal(t, img.GetImageWidth(), 320)
	assert.Equal(t, img.GetImageHeight(), 240)
}

func TestHttpFetchOKBaseUrl(t *testing.T) {
	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, "../data/kth.jpg")
	}))
	defer ts.Close()
	
	provider := NewImageProviderHTTP(ts.URL)
	img, err := provider.Fetch("kth.jpg")
	defer img.Destroy()
	
	assert.Nil(t, err)
	assert.Equal(t, img.GetImageWidth(), 320)
	assert.Equal(t, img.GetImageHeight(), 240)
}
package imgscale

import (
	"github.com/stretchr/testify/assert"
	"testing"
	"net/http"
	"net/http/httptest"
	"fmt"
)

func TestHttpFetchOK(t *testing.T) {
	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, "../data/kth.jpg")
	}))
	defer ts.Close()
	fmt.Println(ts.URL)
	provider := NewImageProviderHTTP("")
	img, err := provider.Fetch(ts.URL)
	defer img.Destroy()
	
	assert.Nil(t, err)
	assert.Equal(t, img.GetImageWidth(), 320)
	assert.Equal(t, img.GetImageHeight(), 240)
}
--- 
+++ 
@@ -5,7 +5,6 @@
 	"testing"
 	"net/http"
 	"net/http/httptest"
-	"fmt"
 )
 
 func TestHttpFetchOK(t *testing.T) {
@@ -13,7 +12,7 @@
 		http.ServeFile(w, r, "../data/kth.jpg")
 	}))
 	defer ts.Close()
-	fmt.Println(ts.URL)
+	
 	provider := NewImageProviderHTTP("")
 	img, err := provider.Fetch(ts.URL)
 	defer img.Destroy()
@@ -22,3 +21,18 @@
 	assert.Equal(t, img.GetImageWidth(), 320)
 	assert.Equal(t, img.GetImageHeight(), 240)
 }
+
+func TestHttpFetchOKBaseUrl(t *testing.T) {
+	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+		http.ServeFile(w, r, "../data/kth.jpg")
+	}))
+	defer ts.Close()
+	
+	provider := NewImageProviderHTTP(ts.URL)
+	img, err := provider.Fetch("kth.jpg")
+	defer img.Destroy()
+	
+	assert.Nil(t, err)
+	assert.Equal(t, img.GetImageWidth(), 320)
+	assert.Equal(t, img.GetImageHeight(), 240)
+}
Test case with none empty base url