File: server_manager_test.go

package info (click to toggle)
ntfy 2.11.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,364 kB
  • sloc: javascript: 16,782; makefile: 282; sh: 105; php: 21; python: 19
file content (29 lines) | stat: -rw-r--r-- 703 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//go:build ignore
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)
}