Fix intergration test after moving functions around
This commit is contained in:
parent
8fce2cd868
commit
d121b115f2
1 changed files with 32 additions and 4 deletions
|
@ -7,17 +7,45 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"orblivion/lbry-id/auth"
|
"orblivion/lbry-id/auth"
|
||||||
"orblivion/lbry-id/store"
|
"orblivion/lbry-id/store"
|
||||||
"orblivion/lbry-id/wallet"
|
"orblivion/lbry-id/wallet"
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Whereas sever_test.go stubs out auth store and wallet, these will use the real thing, but test fewer paths.
|
// Whereas sever_test.go stubs out auth store and wallet, these will use the real thing, but test fewer paths.
|
||||||
|
|
||||||
// TODO - test some unhappy paths? Don't want to retest all the unit tests though.
|
// TODO - test some unhappy paths? Don't want to retest all the unit tests though.
|
||||||
|
|
||||||
|
// Integration test requires a real sqlite database
|
||||||
|
func storeTestInit(t *testing.T) (s store.Store, tmpFile *os.File) {
|
||||||
|
s = store.Store{}
|
||||||
|
|
||||||
|
tmpFile, err := ioutil.TempFile(os.TempDir(), "sqlite-test-")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("DB setup failure: %+v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
s.Init(tmpFile.Name())
|
||||||
|
|
||||||
|
err = s.Migrate()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("DB setup failure: %+v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func storeTestCleanup(tmpFile *os.File) {
|
||||||
|
if tmpFile != nil {
|
||||||
|
os.Remove(tmpFile.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func checkStatusCode(t *testing.T, statusCode int, responseBody []byte, expectedStatusCodeSlice ...int) {
|
func checkStatusCode(t *testing.T, statusCode int, responseBody []byte, expectedStatusCodeSlice ...int) {
|
||||||
var expectedStatusCode int
|
var expectedStatusCode int
|
||||||
if len(expectedStatusCodeSlice) == 1 {
|
if len(expectedStatusCodeSlice) == 1 {
|
||||||
|
@ -59,8 +87,8 @@ func request(t *testing.T, method string, handler func(http.ResponseWriter, *htt
|
||||||
|
|
||||||
// Test some flows with syncing two devices that have the wallet locally.
|
// Test some flows with syncing two devices that have the wallet locally.
|
||||||
func TestIntegrationWalletUpdates(t *testing.T) {
|
func TestIntegrationWalletUpdates(t *testing.T) {
|
||||||
st, tmpFile := store.StoreTestInit(t)
|
st, tmpFile := storeTestInit(t)
|
||||||
defer store.StoreTestCleanup(tmpFile)
|
defer storeTestCleanup(tmpFile)
|
||||||
|
|
||||||
s := Init(&auth.Auth{}, &st)
|
s := Init(&auth.Auth{}, &st)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue