1package test_chdir 2 3import ( 4 "log" 5 "os" 6 "testing" 7) 8 9const file = "data.txt" 10 11func init() { 12 _, err := os.Stat(file) 13 if err != nil { 14 log.Fatalf("in init(), could not stat %s: %v", file, err) 15 } 16} 17 18func TestMain(m *testing.M) { 19 _, err := os.Stat(file) 20 if err != nil { 21 log.Fatalf("in TestMain(), could not stat %s: %v", file, err) 22 } 23 os.Exit(m.Run()) 24} 25 26func TestLocal(t *testing.T) { 27 _, err := os.Stat(file) 28 if err != nil { 29 t.Errorf("could not stat %s: %v", file, err) 30 } 31} 32