Skip to content

Commit

Permalink
try manually removing all the entries we've created.
Browse files Browse the repository at this point in the history
Signed-off-by: Ville Aikas <vaikas@chainguard.dev>
  • Loading branch information
vaikas committed Sep 28, 2022
1 parent 8719f08 commit fa7fdec
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
25 changes: 22 additions & 3 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,28 @@ func (s *ClientSuite) SetUpTest(c *C) {

func (s *ClientSuite) TearDownTest(c *C) {
if s.tmpDir != "" {
// Just ignore the errors, we're done anyways, and this can cause
// grief in windows.
os.RemoveAll(s.tmpDir)
c.Logf("Removing %s", s.tmpDir)
d, err := os.Open(s.tmpDir)
if err != nil {
c.Logf("Failed to open %s: %v", s.tmpDir, err)
return
}
defer d.Close()
// -1 means give me everything, we don't have that many entries, so
// fine here.
names, err := d.Readdirnames(-1)
if err != nil {
c.Logf("Failed to ReaddirNames %s: %v", s.tmpDir, err)
return
}
for _, name := range names {
toRemove := filepath.Join(s.tmpDir, name)
err = os.RemoveAll(toRemove)
if err != nil {
c.Logf("Failed to RemoveAll %s: %v", toRemove, err)
// Do not want to fail here, because will fail test.
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions client/file_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestBasicOps(t *testing.T) {
if err != nil {
t.Errorf("failed to ReadAll returned ReacCloser %s: %v", k, err)
}
if bytes.Compare(v, got) != 0 {
if !bytes.Equal(v, got) {
t.Errorf("Read unexpected bytes, want: %s got: %s", string(k), string(got))
}
}
Expand All @@ -108,7 +108,7 @@ func TestBasicOps(t *testing.T) {
if err != nil {
t.Errorf("failed to ReadAll returned ReacCloser %s: %v", k, err)
}
if bytes.Compare(v, got) != 0 {
if !bytes.Equal(v, got) {
t.Errorf("Read unexpected bytes, want: %s got: %s", string(k), string(got))
}
}
Expand Down

0 comments on commit fa7fdec

Please sign in to comment.