-
-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
binwiederhier
committed
Feb 17, 2023
1 parent
7fb6f79
commit 38e7801
Showing
5 changed files
with
68 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package server | ||
|
||
import ( | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestServer_Manager_Prune_Messages_Without_Attachments_DoesNotPanic(t *testing.T) { | ||
// Tests that the manager runs without attachment-cache-dir set, see #617 | ||
c := newTestConfig(t) | ||
c.AttachmentCacheDir = "" | ||
s := newTestServer(t, c) | ||
|
||
// Publish a message | ||
rr := request(t, s, "POST", "/mytopic", "hi", nil) | ||
require.Equal(t, 200, rr.Code) | ||
m := toMessage(t, rr.Body.String()) | ||
|
||
// Expire message | ||
require.Nil(t, s.messageCache.ExpireMessages("mytopic")) | ||
|
||
// Does not panic | ||
s.pruneMessages() | ||
|
||
// Actually deleted | ||
_, err := s.messageCache.Message(m.ID) | ||
require.Equal(t, errMessageNotFound, err) | ||
} |