delete handler test
This commit is contained in:
12
db/db.go
12
db/db.go
@@ -2,7 +2,6 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
@@ -21,14 +20,3 @@ func New() *gorm.DB {
|
|||||||
}
|
}
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new GORM connection to the mock database
|
|
||||||
func NewMock() *gorm.DB {
|
|
||||||
// projectRoot presumes this file is `<root>/db/db.go`
|
|
||||||
dbPath, _ := filepath.Abs(filepath.Join(cFile, "../../test_data/mock.db"))
|
|
||||||
db, err := gorm.Open("sqlite3", dbPath)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("when opening mock database: %v\n", err)
|
|
||||||
}
|
|
||||||
return db
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.9.0">
|
|
||||||
<albumList2 />
|
|
||||||
<artists>
|
|
||||||
<index name="A">
|
|
||||||
<artist id="1" name="A Certain Ratio" coverArt="0" albumCount="0" />
|
|
||||||
<artist id="3" name="Anikas" coverArt="0" albumCount="0" />
|
|
||||||
</index>
|
|
||||||
<index name="#">
|
|
||||||
<artist id="2" name="13th Floor Elevators" coverArt="0" albumCount="0" />
|
|
||||||
</index>
|
|
||||||
</artists>
|
|
||||||
<musicFolders />
|
|
||||||
</subsonic-response>
|
|
||||||
Reference in New Issue
Block a user