Files
gocryptotrader/exchanges/localbitcoins/localbitcoins_mock_test.go
2019-08-23 21:59:01 +10:00

46 lines
1.2 KiB
Go

//+build !mock_test_off
// This will build if build tag mock_test_off is not parsed and will try to mock
// all tests in _test.go
package localbitcoins
import (
"log"
"os"
"testing"
"github.com/thrasher-corp/gocryptotrader/config"
"github.com/thrasher-corp/gocryptotrader/exchanges/mock"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
)
const mockfile = "../../testdata/http_mock/localbitcoins/localbitcoins.json"
var mockTests = true
func TestMain(m *testing.M) {
cfg := config.GetConfig()
cfg.LoadConfig("../../testdata/configtest.json")
localbitcoinsConfig, err := cfg.GetExchangeConfig("LocalBitcoins")
if err != nil {
log.Fatal("Test Failed - Localbitcoins Setup() init error", err)
}
l.SkipAuthCheck = true
localbitcoinsConfig.API.AuthenticatedSupport = true
localbitcoinsConfig.API.Credentials.Key = apiKey
localbitcoinsConfig.API.Credentials.Secret = apiSecret
l.SetDefaults()
l.Setup(localbitcoinsConfig)
serverDetails, newClient, err := mock.NewVCRServer(mockfile)
if err != nil {
log.Fatalf("Test Failed - Mock server error %s", err)
}
l.HTTPClient = newClient
l.API.Endpoints.URL = serverDetails
log.Printf(sharedtestvalues.MockTesting, l.GetName(), l.API.Endpoints.URL)
os.Exit(m.Run())
}