github.com/Bytom/bytom@v1.1.2-0.20210127130405-ae40204c0b09/node/node_test.go (about) 1 package node 2 3 import ( 4 "io/ioutil" 5 "os" 6 "testing" 7 8 cfg "github.com/bytom/bytom/config" 9 ) 10 11 func TestNodeUsedDataDir(t *testing.T) { 12 dir, err := ioutil.TempDir("", "") 13 if err != nil { 14 t.Fatalf("failed to create temporary data directory: %v", err) 15 } 16 defer os.RemoveAll(dir) 17 var config cfg.Config 18 config.RootDir = dir 19 if err := lockDataDirectory(&config); err != nil { 20 t.Fatalf("Error: %v", err) 21 } 22 23 if err := lockDataDirectory(&config); err == nil { 24 t.Fatalf("duplicate datadir failure mismatch: want %v", err) 25 } 26 }