Skip to content

Commit

Permalink
[test] refs fibercrypto#143 - Add Makefile command for test coverage …
Browse files Browse the repository at this point in the history
…and add coverage files in gitignore.

Use make test-cover for test coverage.
  • Loading branch information
AntiD2ta committed Nov 7, 2019
1 parent 64c9b50 commit 76845b8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ rcc__*
# Temporary build files
rcc_cgo_*.go


src/coin/skycoin/coverage.html

src/coin/skycoin/coverage.out
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
UNAME_S = $(shell uname -s)
DEFAULT_TARGET ?= desktop
DEFAULT_ARCH ?= linux
COIN = skycoin ##In future use as a parameter tu make command.
COVERAGEPATH = src/coin/$(COIN)
COVERAGEFILE = $(COVERAGEPATH)/coverage.out
COVERAGEHTML = $(COVERAGEPATH)/coverage.html

deps: ## Add dependencies
dep ensure
Expand Down Expand Up @@ -81,8 +85,19 @@ clean: ## Clean project FiberCrypto Wallet.
@echo "Done."

test-sky: ## Run Skycoin plugin test suite
go test -timeout 30s github.com/fibercrypto/FiberCryptoWallet/src/coin/skycoin
go test -timeout 30s github.com/fibercrypto/FiberCryptoWallet/src/coin/skycoin/models
go test -cover -timeout 30s github.com/fibercrypto/FiberCryptoWallet/src/coin/skycoin
go test -coverprofile=$(COVERAGEFILE) -timeout 30s github.com/fibercrypto/FiberCryptoWallet/src/coin/skycoin/models

test-clean:
rm $(COVERAGEFILE)
rm $(COVERAGEHTML)

test-sky-launch-html-cover:
go test -cover -timeout 30s github.com/fibercrypto/FiberCryptoWallet/src/coin/skycoin
go test -coverprofile=$(COVERAGEFILE) -timeout 30s github.com/fibercrypto/FiberCryptoWallet/src/coin/skycoin/models
go tool cover -html=$(COVERAGEFILE) -o $(COVERAGEHTML)

test-cover: test-sky-launch-html-cover ## Show more details of test coverage

test: test-sky ## Run project test suite

Expand Down
9 changes: 6 additions & 3 deletions src/coin/skycoin/models/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ func TestRemoteWalletTransfer(t *testing.T) {
Type: 0,
InnerHash: hash,
}
crtTxn, _ := api.NewCreateTransactionResponse(&txn, nil)
crtTxn, err := api.NewCreateTransactionResponse(&txn, nil)
require.Nil(t, err)
crtTxn.Transaction.Fee = "500"

mockSkyApiWalletCreateTransaction(global_mock, &wreq, crtTxn)
Expand Down Expand Up @@ -387,7 +388,8 @@ func TestRemoteWalletSendFromAddress(t *testing.T) {
Type: 0,
InnerHash: hash,
}
crtTxn, _ := api.NewCreateTransactionResponse(&txn, nil)
crtTxn, err := api.NewCreateTransactionResponse(&txn, nil)
require.Nil(t, err)
crtTxn.Transaction.Fee = strconv.Itoa(sky)

mockSkyApiWalletCreateTransaction(global_mock, &wreq1, crtTxn)
Expand Down Expand Up @@ -473,7 +475,8 @@ func TestRemoteWalletSpend(t *testing.T) {
Type: 0,
InnerHash: hash,
}
crtTxn, _ := api.NewCreateTransactionResponse(&txn, nil)
crtTxn, err := api.NewCreateTransactionResponse(&txn, nil)
require.Nil(t, err)
crtTxn.Transaction.Fee = "500"

mockSkyApiWalletCreateTransaction(global_mock, &wreq, crtTxn)
Expand Down

0 comments on commit 76845b8

Please sign in to comment.