forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of HTTP mock testing framework (thrasher-corp#310
) * Initial implementation of HTTP mock testing framework Convert to VCR testing server. Segregate live testing via build tags. Converted Binance to VCR server Convert Bitstamp to VCR mocking tests Added VCR mock testing for localbitcoins * Add server generation for concurrent testing * Fix linter issues * Fix linter issue * fix race - potentially * revert auto assigning of host vals * Fix requested changes * Adds mock testing for ANX Switch to using TestMain functionality Added cron job usage for travis-ci to live testing Added appveyor scheduled build check for live testing * WOOPS * silly correction * Fixes fantastic linter issues * fixed another whoopsie * WOOO! * Adds gemini mock testing with additional fixes * Add docs and sharedvalue * Added tls using httptest package * Fixed issues * added explicit mock recording reference to error * Fix requested changes * strip port from mock files as they are not needed on tls server * Change incorrect names * fix requested changes * lbank update * Fix another issue * Updated readme
- Loading branch information
Showing
79 changed files
with
109,267 additions
and
1,249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,12 @@ test_script: | |
# test back-end | ||
- go get github.com/golangci/golangci-lint/cmd/[email protected] | ||
- '%GOPATH%\bin\golangci-lint.exe run --verbose' | ||
- go test -race ./... | ||
- ps: >- | ||
if($env:APPVEYOR_SCHEDULED_BUILD -eq 'true') { | ||
go test -race ./... -tags=mock_test_off | ||
}else { | ||
go test -race ./... | ||
} | ||
# test front-end | ||
- node --version | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ LINTPKG = github.com/golangci/golangci-lint/cmd/[email protected] | |
LINTBIN = $(GOPATH)/bin/golangci-lint | ||
GCTLISTENPORT=9050 | ||
GCTPROFILERLISTENPORT=8085 | ||
CRON = $(TRAVIS_EVENT_TYPE) | ||
|
||
get: | ||
GO111MODULE=on go get $(GCTPKG) | ||
|
@@ -16,7 +17,11 @@ linter: | |
check: linter test | ||
|
||
test: | ||
ifeq ($(CRON), cron) | ||
go test -race -tags=mock_test_off -coverprofile=coverage.txt -covermode=atomic ./... | ||
else | ||
go test -race -coverprofile=coverage.txt -covermode=atomic ./... | ||
endif | ||
|
||
build: | ||
GO111MODULE=on go build $(LDFLAGS) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//+build mock_test_off | ||
|
||
// This will build if build tag mock_test_off is parsed and will do live testing | ||
// using all tests in (exchange)_test.go | ||
package anx | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"testing" | ||
|
||
"github.com/thrasher-corp/gocryptotrader/config" | ||
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues" | ||
) | ||
|
||
var mockTests = false | ||
|
||
func TestMain(m *testing.M) { | ||
cfg := config.GetConfig() | ||
cfg.LoadConfig("../../testdata/configtest.json") | ||
anxConfig, err := cfg.GetExchangeConfig("ANX") | ||
if err != nil { | ||
log.Fatalf("Test Failed - ANX Setup() init error", err) | ||
} | ||
anxConfig.AuthenticatedAPISupport = true | ||
anxConfig.APIKey = apiKey | ||
anxConfig.APISecret = apiSecret | ||
a.SetDefaults() | ||
a.Setup(&anxConfig) | ||
log.Printf(sharedtestvalues.LiveTesting, a.GetName(), a.APIUrl) | ||
os.Exit(m.Run()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//+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 anx | ||
|
||
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/anx/anx.json" | ||
|
||
var mockTests = true | ||
|
||
func TestMain(m *testing.M) { | ||
cfg := config.GetConfig() | ||
cfg.LoadConfig("../../testdata/configtest.json") | ||
anxConfig, err := cfg.GetExchangeConfig("ANX") | ||
if err != nil { | ||
log.Fatal("Test Failed - Mock server error", err) | ||
} | ||
anxConfig.AuthenticatedAPISupport = true | ||
anxConfig.APIKey = apiKey | ||
anxConfig.APISecret = apiSecret | ||
a.SetDefaults() | ||
a.Setup(&anxConfig) | ||
|
||
serverDetails, newClient, err := mock.NewVCRServer(mockFile) | ||
if err != nil { | ||
log.Fatalf("Test Failed - Mock server error %s", err) | ||
} | ||
|
||
a.HTTPClient = newClient | ||
a.APIUrl = serverDetails + "/" | ||
|
||
log.Printf(sharedtestvalues.MockTesting, a.GetName(), a.APIUrl) | ||
os.Exit(m.Run()) | ||
} |
Oops, something went wrong.