Skip to content

Commit

Permalink
use *testing.T.TempDir()
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessio Treglia committed Sep 18, 2020
1 parent eb3f010 commit 108e780
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
7 changes: 2 additions & 5 deletions x/distribution/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"context"
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -687,9 +686,8 @@ func (s *IntegrationTestSuite) TestNewFundCommunityPoolCmd() {
func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() {
val := s.network.Validators[0]

invalidPropFile, err := ioutil.TempFile(os.TempDir(), "invalid_community_spend_proposal.*.json")
invalidPropFile, err := ioutil.TempFile(s.T().TempDir(), "invalid_community_spend_proposal.*.json")
s.Require().NoError(err)
defer os.Remove(invalidPropFile.Name())

invalidProp := `{
"title": "",
Expand All @@ -702,9 +700,8 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() {
_, err = invalidPropFile.WriteString(invalidProp)
s.Require().NoError(err)

validPropFile, err := ioutil.TempFile(os.TempDir(), "valid_community_spend_proposal.*.json")
validPropFile, err := ioutil.TempFile(s.T().TempDir(), "valid_community_spend_proposal.*.json")
s.Require().NoError(err)
defer os.Remove(validPropFile.Name())

validProp := fmt.Sprintf(`{
"title": "Community Pool Spend",
Expand Down
7 changes: 2 additions & 5 deletions x/gov/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package cli_test
import (
"fmt"
"io/ioutil"
"os"
"testing"

"github.com/gogo/protobuf/proto"
Expand Down Expand Up @@ -47,9 +46,8 @@ func (s *IntegrationTestSuite) TearDownSuite() {
func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
val := s.network.Validators[0]

invalidPropFile, err := ioutil.TempFile(os.TempDir(), "invalid_text_proposal.*.json")
invalidPropFile, err := ioutil.TempFile(s.T().TempDir(), "invalid_text_proposal.*.json")
s.Require().NoError(err)
defer os.Remove(invalidPropFile.Name())

invalidProp := `{
"title": "",
Expand All @@ -61,9 +59,8 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
_, err = invalidPropFile.WriteString(invalidProp)
s.Require().NoError(err)

validPropFile, err := ioutil.TempFile(os.TempDir(), "valid_text_proposal.*.json")
validPropFile, err := ioutil.TempFile(s.T().TempDir(), "valid_text_proposal.*.json")
s.Require().NoError(err)
defer os.Remove(validPropFile.Name())

validProp := fmt.Sprintf(`{
"title": "Text Proposal",
Expand Down
4 changes: 2 additions & 2 deletions x/upgrade/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package keeper_test

import (
"os"
"path/filepath"
"testing"

Expand All @@ -22,10 +21,11 @@ type KeeperTestSuite struct {

func (s *KeeperTestSuite) SetupTest() {
app := simapp.Setup(false)
homeDir := filepath.Join(os.TempDir(), "x_upgrade_keeper_test")
homeDir := filepath.Join(s.T().TempDir(), "x_upgrade_keeper_test")
app.UpgradeKeeper = keeper.NewKeeper( // recreate keeper in order to use a custom home path
make(map[int64]bool), app.GetKey(types.StoreKey), app.AppCodec(), homeDir,
)
s.T().Log("home dir:", homeDir)
s.homeDir = homeDir
s.app = app
}
Expand Down

0 comments on commit 108e780

Please sign in to comment.