Commit 88402fc 1 parent 241c162 commit 88402fc Copy full SHA for 88402fc
File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 6
6
"testing"
7
7
"time"
8
8
9
+ "github.com/centrifugal/centrifugo/v5/internal/tools"
10
+
9
11
"github.com/stretchr/testify/require"
10
12
)
11
13
@@ -100,6 +102,39 @@ func TestConfigValidatePersonalSingleConnectionOK(t *testing.T) {
100
102
require .NoError (t , err )
101
103
}
102
104
105
+ func TestConfigValidateHistoryTTL (t * testing.T ) {
106
+ t .Run ("in_namespace" , func (t * testing.T ) {
107
+ c := DefaultConfig
108
+ c .Namespaces = []ChannelNamespace {
109
+ {
110
+ Name : "name1" ,
111
+ ChannelOptions : ChannelOptions {
112
+ HistorySize : 10 ,
113
+ HistoryTTL : tools .Duration (20 * time .Second ),
114
+ HistoryMetaTTL : tools .Duration (10 * time .Second ),
115
+ },
116
+ },
117
+ }
118
+ err := c .Validate ()
119
+ require .ErrorContains (t , err , "history meta ttl" )
120
+ })
121
+ t .Run ("on_top_level" , func (t * testing.T ) {
122
+ c := DefaultConfig
123
+ c .HistorySize = 10
124
+ c .HistoryTTL = tools .Duration (31 * 24 * time .Hour )
125
+ err := c .Validate ()
126
+ require .ErrorContains (t , err , "history meta ttl" )
127
+ })
128
+ t .Run ("top_level_non_default_global" , func (t * testing.T ) {
129
+ c := DefaultConfig
130
+ c .GlobalHistoryMetaTTL = 10 * time .Hour
131
+ c .HistorySize = 10
132
+ c .HistoryTTL = tools .Duration (30 * 24 * time .Hour )
133
+ err := c .Validate ()
134
+ require .ErrorContains (t , err , "history meta ttl" )
135
+ })
136
+ }
137
+
103
138
func TestConfigValidatePersonalSingleConnectionNamespacedFail (t * testing.T ) {
104
139
c := DefaultConfig
105
140
c .Namespaces = []ChannelNamespace {}
You can’t perform that action at this time.
0 commit comments