Merge pull request #24 from fvosberg/fix-test-chdir-sideeffect

[PATCH] Remove side effect caused by chdir from test - fixes #23
This commit is contained in:
Mat Ryer 2017-07-31 14:59:10 +01:00 committed by GitHub
commit 9999c4d497

View File

@ -196,10 +196,20 @@ func TestVendoredPackages(t *testing.T) {
// TestDotImports tests for https://github.com/matryer/moq/issues/21.
func TestDotImports(t *testing.T) {
err := os.Chdir("testpackages/dotimport")
preDir, err := os.Getwd()
if err != nil {
t.Errorf("Getwd: %s", err)
}
err = os.Chdir("testpackages/dotimport")
if err != nil {
t.Errorf("Chdir: %s", err)
}
defer func() {
err := os.Chdir(preDir)
if err != nil {
t.Errorf("Chdir back: %s", err)
}
}()
m, err := New(".", "moqtest_test")
if err != nil {
t.Fatalf("moq.New: %s", err)