Skip to content

Commit

Permalink
fix: clean cache test
Browse files Browse the repository at this point in the history
  • Loading branch information
radulucut committed Aug 15, 2024
1 parent 2e2e1c5 commit 6a17be6
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions cmd/cleed/unfollow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cleed
import (
"bytes"
"fmt"
"net/url"
"os"
"path"
"testing"
Expand Down Expand Up @@ -270,12 +271,12 @@ https://test.com was removed from the list
ETag: "etag",
}, cacheInfo["https://test.com"])

_, err = storage.OpenFeedCache("https://example.com")
assert.Error(t, err)
f, err := storage.OpenFeedCache("https://test.com")
assert.NoError(t, err)
b := new(bytes.Buffer)
_, err = b.ReadFrom(f)
assert.NoError(t, err)
assert.Equal(t, "test", b.String())
_, err = os.Stat("https://example.com")
assert.ErrorIs(t, err, os.ErrNotExist)

b, err := os.ReadFile(path.Join(cacheDir, "feed_"+url.QueryEscape("https://test.com")))
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "test", string(b))
}

0 comments on commit 6a17be6

Please sign in to comment.