-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_local.rb
60 lines (54 loc) · 1.22 KB
/
test_local.rb
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true
require 'json'
require_relative '../lib/changelogerator'
require_relative '../lib/change'
require 'test/unit'
class TestLocal < Test::Unit::TestCase
def test_meta_1_commit
change = Change.new(%w[A1-foo A2-foo B0-foo B1-foo B2-foo])
Changelog.compute_change_meta(change)
assert_equal(%w[A B], change.meta.keys)
assert_equal(change.meta['A']['agg']['min'], 1) # A(1)
assert_equal(change.meta['A']['agg']['max'], 2) # A(2)
assert_equal(change.meta['A']['agg']['count'], 2) # A1 + A2
assert_equal(change.meta['B']['agg']['min'], 0) # B(0)
assert_equal(change.meta['B']['agg']['max'], 2) # B(2)
assert_equal(change.meta['B']['agg']['count'], 3) # B0 + B1 + B2
assert_equal(JSON.pretty_generate(change.meta), '{
"A": {
"agg": {
"count": 2,
"max": 2,
"min": 1
},
"A1": {
"value": 1,
"text": "foo"
},
"A2": {
"value": 2,
"text": "foo"
}
},
"B": {
"agg": {
"count": 3,
"max": 2,
"min": 0
},
"B0": {
"value": 0,
"text": "foo"
},
"B1": {
"value": 1,
"text": "foo"
},
"B2": {
"value": 2,
"text": "foo"
}
}
}')
end
end