Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
fix TestSourceManagerInit
Browse files Browse the repository at this point in the history
- Re-create cache directory before trying to call `NewSourceManager` the 2nd
  time and defer it's removal.
- If `NewSourceManager` fails the 2nd time, exit the error using `t.Fatal` to
  avoid panic in `sm.Release`
  • Loading branch information
sudo-suhas committed Dec 2, 2017
1 parent 398de52 commit c4c6c51
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions gps/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,23 @@ func TestSourceManagerInit(t *testing.T) {
t.Fatalf("Global cache lock file not cleared correctly on Release()")
}

err = os.MkdirAll(cpath, 0777)
if err != nil {
t.Errorf("Failed to re-create temp dir: %s", err)
}
defer func() {
err = os.RemoveAll(cpath)
if err != nil {
t.Errorf("removeAll failed: %s", err)
}
}()
// Set another one up at the same spot now, just to be sure
sm, err = NewSourceManager(cfg)
if err != nil {
t.Errorf("Creating a second SourceManager should have succeeded when the first was released, but failed with err %s", err)
t.Fatalf("Creating a second SourceManager should have succeeded when the first was released, but failed with err %s", err)
}

sm.Release()
err = os.RemoveAll(cpath)
if err != nil {
t.Errorf("removeAll failed: %s", err)
}
}

func TestSourceInit(t *testing.T) {
Expand Down

0 comments on commit c4c6c51

Please sign in to comment.