This commit is contained in:
sentriz
2019-04-29 17:39:36 +01:00
parent 669bc2f6bc
commit 27981ae3cf
6 changed files with 70 additions and 17 deletions

View File

@@ -0,0 +1,27 @@
package handler
import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"github.com/sentriz/gonic/db"
)
var mockController = Controller{
DB: db.NewMock(),
}
func TestGetArtists(t *testing.T) {
rr := httptest.NewRecorder()
r, _ := http.NewRequest("GET", "", nil)
handler := http.HandlerFunc(mockController.GetArtists)
handler.ServeHTTP(rr, r)
dat, _ := ioutil.ReadFile("../test_data/mock_getArtists_response")
fmt.Println(string(dat))
fmt.Println(rr.Body)
}

View File

@@ -35,7 +35,7 @@ func respondRaw(w http.ResponseWriter, r *http.Request,
w.Write([]byte(");"))
default:
w.Header().Set("Content-Type", "application/xml")
data, err := xml.Marshal(res)
data, err := xml.MarshalIndent(res, "", " ")
if err != nil {
log.Printf("could not marshall to xml: %v\n", err)
}