mux t
This commit is contained in:
27
handler/handler_sub_test.go
Normal file
27
handler/handler_sub_test.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user