2014-11-29 17:42:22 -05:00
|
|
|
package storage
|
2014-11-02 18:56:33 -05:00
|
|
|
|
|
|
|
import (
|
2014-12-08 17:25:57 -05:00
|
|
|
"fmt"
|
2014-11-02 18:56:33 -05:00
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPrintsStorage(t *testing.T) {
|
2014-12-08 17:25:57 -05:00
|
|
|
server := httptest.NewServer(http.HandlerFunc(storageHandler))
|
2014-11-02 18:56:33 -05:00
|
|
|
defer server.Close()
|
|
|
|
res, err := http.Get(server.URL)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
|
|
res.Body.Close()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
bodyString := string(body)
|
|
|
|
if bodyString != "Storage" {
|
|
|
|
log.Fatal("Expected 'Storage', Received '" + bodyString + "'")
|
|
|
|
}
|
|
|
|
}
|
2014-12-08 17:25:57 -05:00
|
|
|
|
|
|
|
func storageHandler(w http.ResponseWriter, req *http.Request) {
|
|
|
|
fmt.Fprintf(w, "Storage")
|
|
|
|
}
|