Skip to content

Commit

Permalink
Add tests for NewMultiWallet
Browse files Browse the repository at this point in the history
  • Loading branch information
oluwandabira committed Jan 18, 2020
1 parent 6afa762 commit fba6981
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 19 deletions.
34 changes: 15 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
name: Go
name: Build and Test
on: [push]
jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go

- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1


- name: Build, run tests and vet
run: |
go build
go test
go vet
env:
GO111MODULE: "on"
- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Build, run tests and vet
run: |
go build
go test
go vet
env:
GO111MODULE: "on"
35 changes: 35 additions & 0 deletions multiwallet_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package dcrlibwallet_test

import (
"os"
"testing"
"testing/quick"

. "github.com/raedahgroup/dcrlibwallet"
)

// canUseDir returns true if the program can create the directory
// if it doesn't exist or the directory is empty if it exists.
// If will delete the directory if it is empty.
func canUseDir(directory string) bool {
if os.MkdirAll(directory, os.ModePerm) == nil {
return os.Remove(directory) == nil
}
return false
}

// TestNewMultiWallet tests if NewMultiWallet will return an error for valid
// paths or not return an error for invalid paths
func TestNewMultiWallet(t *testing.T) {
f := func(rootDir string) bool {
canUse := canUseDir(rootDir)
_, err := NewMultiWallet(rootDir, "", "testnet")
if canUse {
return err == nil
}
return err != nil
}
if err := quick.Check(f, nil); err != nil {
t.Error(err)
}
}

0 comments on commit fba6981

Please sign in to comment.