UNPKG

2.94 kBtext/coffeescriptView Raw
1ger_tests = (ESM) ->
2 ns = global.default_namespace
3
4 describe "compact ", ->
5
6 describe "compact_database_thing_action_limit", ->
7 it 'should truncate events on a thing to the set limit', ->
8 init_ger(ESM)
9 .then (ger) ->
10 bb.all([
11 ger.event(ns, 'p1','view','t1')
12 ger.event(ns, 'p2','view','t1')
13 ger.event(ns, 'p3','view','t1')
14
15 ger.event(ns, 'p1','view','t2')
16 ger.event(ns, 'p2','view','t2')
17 ])
18 .then( ->
19 ger.count_events(ns)
20 )
21 .then( (count) ->
22 count.should.equal 5
23 )
24 .then( ->
25 ger.compact_database(ns, compact_database_thing_action_limit: 2, actions: ['view'])
26 )
27 .then( ->
28 ger.compact_database(ns, compact_database_thing_action_limit: 2, actions: ['view'])
29 )
30 .then( ->
31 ger.count_events(ns)
32 )
33 .then( (count) ->
34 count.should.equal 4
35 )
36
37 describe "compact_database_person_action_limit", ->
38 it 'should truncate events by a person to the set limit', ->
39 init_ger(ESM)
40 .then (ger) ->
41 bb.all([
42 ger.event(ns, 'p1','view','t1')
43 ger.event(ns, 'p1','view','t2')
44 ger.event(ns, 'p1','view','t3')
45 ger.event(ns, 'p1','view','t4')
46 ger.event(ns, 'p1','view','t5')
47
48 ger.event(ns, 'p2','view','t2')
49 ger.event(ns, 'p2','view','t3')
50 ])
51 .then( ->
52 ger.count_events(ns)
53 )
54 .then( (count) ->
55 count.should.equal 7
56 )
57 .then( ->
58 ger.compact_database(ns, compact_database_person_action_limit: 2, actions: ['view'])
59 )
60 .then( ->
61 ger.compact_database(ns, compact_database_person_action_limit: 2, actions: ['view'])
62 )
63 .then( ->
64 ger.count_events(ns)
65 )
66 .then( (count) ->
67 count.should.equal 4
68 )
69
70
71
72 it 'should not deadlock', ->
73 init_ger(ESM)
74 .then (ger) ->
75 bb.all([
76 ger.event(ns, 'p1','view','t1')
77 ger.event(ns, 'p1','view','t2')
78 ger.event(ns, 'p1','view','t3', created_at: yesterday) #this row should be deleted twice
79
80 ger.event(ns, 'p2','view','t3')
81 ger.event(ns, 'p3','view','t3')
82 ])
83 .then( ->
84 ger.count_events(ns)
85 )
86 .then( (count) ->
87 count.should.equal 5
88 )
89 .then( ->
90 ger.compact_database(ns, {
91 compact_database_thing_action_limit: 2,
92 compact_database_person_action_limit: 2,
93 actions: ['view']
94 })
95 )
96 .then( ->
97 ger.count_events(ns)
98 )
99 .then( (count) ->
100 count.should.equal 4
101 )
102
103module.exports = ger_tests;
\No newline at end of file