// TestMain creates temporary copies of gomod and gosum so the tests will pass.
// Since resulting go.sum will change depending latest bitx dependencies, these copies are deleted afterwards.
// See testdata/example/doc.go for more details.
TestMain creates temporary copies of gomod and gosum so the tests will pass.
Since resulting go.sum will change depending latest bitx dependencies, these copies are deleted afterwards.
See testdata/example/doc.go for more details.
// TestMain creates temporary copies of gomod and gosum so the tests will pass . // Since resulting go . sum will change depending latest bitx dependencies these copies are deleted afterwards . // See testdata / example / doc . go for more details .
func TestMain(m *testing.M) {
	copies := map[string]string{
		"testdata/example/gomod": "testdata/example/go.mod",
		"testdata/example/gosum": "testdata/example/go.sum",
	}
	for actual, expect := range copies {
		b, err := ioutil.ReadFile(actual)
		if err != nil {
			log.Error(nil, errors.Wrap(err, "reading file"))
			os.Exit(1)
		}
		err = ioutil.WriteFile(expect, b, 0644)
		if err != nil {
			log.Error(nil, errors.Wrap(err, "writing file"))
			os.Exit(1)
		}
	}
	cmd := exec.Command("go", "mod", "tidy")
	cmd.Dir = "testdata/example"
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	err := cmd.Run()
	if err != nil {
		log.Error(nil, errors.Wrap(err, "go mody tidy"))
		os.Exit(1)
	}
	m.Run()
	for _, expect := range copies {
		err := os.Remove(expect)
		if err != nil {
			log.Error(nil, errors.Wrap(err, "delete"))
			os.Exit(1)
		}
	}
}
func TestMain ( m * testing . M ) { copies := map [ string ] string { " " : " " , " " : " " , } for actual , expect := range copies { b , err := ioutil . ReadFile ( actual ) if err != nil { log . Error ( nil , errors . Wrap ( err , " " ) ) os . Exit ( 1 ) } err = ioutil . WriteFile ( expect , b , 0644 ) if err != nil { log . Error ( nil , errors . Wrap ( err , " " ) ) os . Exit ( 1 ) } } cmd := exec . Command ( " " , " " , " " ) cmd . Dir = " " cmd . Stdout = os . Stdout cmd . Stderr = os . Stderr err := cmd . Run ( ) if err != nil { log . Error ( nil , errors . Wrap ( err , " " ) ) os . Exit ( 1 ) } m . Run ( ) for _ , expect := range copies { err := os . Remove ( expect ) if err != nil { log . Error ( nil , errors . Wrap ( err , " " ) ) os . Exit ( 1 ) } } }
TestMain creates temporary copies of gomod and gosum so the tests will pass.
TestMain creates temporary copies of gomod and gosum so the tests will pass .
// Create copies // Delete copies