From 27e30bedf27e3ddbf82358ce009db0022162abcc Mon Sep 17 00:00:00 2001 From: Silas Davis <silas@erisindustries.com> Date: Wed, 6 Jul 2016 15:54:11 +0100 Subject: [PATCH] Not sure why deferred not being called --- core/config.go | 1 - rpc/tendermint/test/common_test.go | 4 +++- rpc/tendermint/test/shared.go | 5 +++++ test/fixtures/file_fixtures.go | 6 ++++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/config.go b/core/config.go index 8a39f920..941b5b54 100644 --- a/core/config.go +++ b/core/config.go @@ -54,7 +54,6 @@ func loadModuleConfigFromDo(do *definitions.Do, module string) (*config.ModuleCo func LoadModuleConfig(conf *viper.Viper, rootWorkDir, rootDataDir, genesisFile, chainId, module string) (*config.ModuleConfig, error) { moduleName := conf.GetString("chain." + module + ".name") - fmt.Println(conf) majorVersion := conf.GetInt("chain." + module + ".major_version") minorVersion := conf.GetInt("chain." + module + ".minor_version") minorVersionString := version.MakeMinorVersionString(moduleName, majorVersion, diff --git a/rpc/tendermint/test/common_test.go b/rpc/tendermint/test/common_test.go index bc0ca59b..871df79e 100644 --- a/rpc/tendermint/test/common_test.go +++ b/rpc/tendermint/test/common_test.go @@ -4,12 +4,14 @@ import ( "testing" "github.com/eris-ltd/eris-db/test/fixtures" "os" + "fmt" ) // Needs to be in a _test.go file to be picked up func TestMain(m *testing.M) { - ffs := fixtures.NewFileFixtures() + ffs := fixtures.NewFileFixtures("Eris-DB") defer ffs.RemoveAll() + fmt.Println("Defered!!") initGlobalVariables(ffs) diff --git a/rpc/tendermint/test/shared.go b/rpc/tendermint/test/shared.go index 20c996fc..b6044544 100644 --- a/rpc/tendermint/test/shared.go +++ b/rpc/tendermint/test/shared.go @@ -48,6 +48,11 @@ func initGlobalVariables(ffs *fixtures.FileFixtures) { testConfig := viper.New() testConfig.SetConfigFile(testConfigFile) + err := testConfig.ReadInConfig() + + if err != nil { + panic(err) + } chainID = testConfig.GetString("chain.assert_chain_id") rpcAddr := testConfig.GetString("erismint.tendermint_host") diff --git a/test/fixtures/file_fixtures.go b/test/fixtures/file_fixtures.go index 67fa0405..a17933e4 100644 --- a/test/fixtures/file_fixtures.go +++ b/test/fixtures/file_fixtures.go @@ -4,6 +4,7 @@ import ( "github.com/docker/docker/pkg/ioutils" "path" "os" + "fmt" ) // FileFixtures writes files to a temporary location for use in testing. @@ -17,8 +18,8 @@ type FileFixtures struct { // and file contents. The file names will be interpreted as relative to some // temporary root directory that is fixed when allocate() is called on the // FileFixtures struct. -func NewFileFixtures() *FileFixtures { - dir, err := ioutils.TempDir("", "FileFixtures") +func NewFileFixtures(identifyingPrefix string) *FileFixtures { + dir, err := ioutils.TempDir("", identifyingPrefix) return &FileFixtures{ tempDir: dir, Error: err, @@ -53,6 +54,7 @@ func (ffs *FileFixtures) AddDir(name string) string { // Cleans up the the temporary files (with fire) func (ffs *FileFixtures) RemoveAll() { + fmt.Println("cleanup!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") if err := os.RemoveAll(ffs.tempDir); err != nil { // Since we expect to be called from being deferred in a test it's // better if we panic here so that the caller finds -- GitLab