server_manager_test.go 685 B

12345678910111213141516171819202122232425262728
  1. package server
  2. import (
  3. "github.com/stretchr/testify/require"
  4. "testing"
  5. )
  6. func TestServer_Manager_Prune_Messages_Without_Attachments_DoesNotPanic(t *testing.T) {
  7. // Tests that the manager runs without attachment-cache-dir set, see #617
  8. c := newTestConfig(t)
  9. c.AttachmentCacheDir = ""
  10. s := newTestServer(t, c)
  11. // Publish a message
  12. rr := request(t, s, "POST", "/mytopic", "hi", nil)
  13. require.Equal(t, 200, rr.Code)
  14. m := toMessage(t, rr.Body.String())
  15. // Expire message
  16. require.Nil(t, s.messageCache.ExpireMessages("mytopic"))
  17. // Does not panic
  18. s.pruneMessages()
  19. // Actually deleted
  20. _, err := s.messageCache.Message(m.ID)
  21. require.Equal(t, errMessageNotFound, err)
  22. }