fbe 0.29.1 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/typos.yml +1 -1
- data/Gemfile.lock +4 -4
- data/fbe.gemspec +1 -1
- data/lib/fbe/conclude.rb +27 -10
- data/lib/fbe/unmask_repos.rb +11 -2
- data/lib/fbe.rb +1 -1
- metadata +1 -31
- data/renovate.json +0 -6
- data/test/fbe/middleware/test_formatter.rb +0 -104
- data/test/fbe/middleware/test_rate_limit.rb +0 -152
- data/test/fbe/middleware/test_sqlite_store.rb +0 -446
- data/test/fbe/middleware/test_trace.rb +0 -168
- data/test/fbe/test_award.rb +0 -126
- data/test/fbe/test_bylaws.rb +0 -111
- data/test/fbe/test_conclude.rb +0 -172
- data/test/fbe/test_copy.rb +0 -39
- data/test/fbe/test_delete.rb +0 -117
- data/test/fbe/test_delete_one.rb +0 -56
- data/test/fbe/test_enter.rb +0 -35
- data/test/fbe/test_fb.rb +0 -102
- data/test/fbe/test_github_graph.rb +0 -169
- data/test/fbe/test_if_absent.rb +0 -107
- data/test/fbe/test_issue.rb +0 -26
- data/test/fbe/test_iterate.rb +0 -253
- data/test/fbe/test_just_one.rb +0 -33
- data/test/fbe/test_kill_if.rb +0 -39
- data/test/fbe/test_octo.rb +0 -791
- data/test/fbe/test_overwrite.rb +0 -103
- data/test/fbe/test_pmp.rb +0 -34
- data/test/fbe/test_regularly.rb +0 -27
- data/test/fbe/test_repeatedly.rb +0 -31
- data/test/fbe/test_sec.rb +0 -21
- data/test/fbe/test_tombstone.rb +0 -56
- data/test/fbe/test_unmask_repos.rb +0 -66
- data/test/fbe/test_who.rb +0 -25
- data/test/test__helper.rb +0 -45
- data/test/test_fbe.rb +0 -17
data/test/fbe/test_fb.rb
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
|
4
|
-
# SPDX-License-Identifier: MIT
|
5
|
-
|
6
|
-
require 'factbase'
|
7
|
-
require 'judges/options'
|
8
|
-
require 'loog'
|
9
|
-
require_relative '../../lib/fbe'
|
10
|
-
require_relative '../../lib/fbe/fb'
|
11
|
-
require_relative '../test__helper'
|
12
|
-
|
13
|
-
# Test.
|
14
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
15
|
-
# Copyright:: Copyright (c) 2024-2025 Zerocracy
|
16
|
-
# License:: MIT
|
17
|
-
class TestFb < Fbe::Test
|
18
|
-
def test_simple
|
19
|
-
$fb = Factbase.new
|
20
|
-
$global = {}
|
21
|
-
$options = Judges::Options.new
|
22
|
-
$loog = Loog::Buffer.new
|
23
|
-
Fbe.fb.insert.foo = 1
|
24
|
-
Fbe.fb.insert.bar = 2
|
25
|
-
assert_equal(1, Fbe.fb.query('(exists bar)').each.to_a.size)
|
26
|
-
stdout = $loog.to_s
|
27
|
-
assert_includes(stdout, 'Inserted new fact #1', stdout)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_defends_against_improper_facts
|
31
|
-
$fb = Factbase.new
|
32
|
-
$global = {}
|
33
|
-
$options = Judges::Options.new
|
34
|
-
$loog = Loog::Buffer.new
|
35
|
-
assert_raises(StandardError, 'issue without repository') do
|
36
|
-
Fbe.fb.txn do |fbt|
|
37
|
-
f = fbt.insert
|
38
|
-
f.what = 'issue-was-opened'
|
39
|
-
f.issue = 42
|
40
|
-
f.where = 'github'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
assert_raises(StandardError, 'repository without where') do
|
44
|
-
Fbe.fb.txn do |fbt|
|
45
|
-
f = fbt.insert
|
46
|
-
f.what = 'issue-was-opened'
|
47
|
-
f.repository = 44
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_defends_against_duplicates
|
53
|
-
$fb = Factbase.new
|
54
|
-
$global = {}
|
55
|
-
$options = Judges::Options.new
|
56
|
-
$loog = Loog::Buffer.new
|
57
|
-
assert_raises(StandardError) do
|
58
|
-
Fbe.fb.insert.then do |f|
|
59
|
-
f._id = 42
|
60
|
-
f._id = 43
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_sets_job
|
66
|
-
$fb = Factbase.new
|
67
|
-
$global = {}
|
68
|
-
$options = Judges::Options.new(job_id: 42)
|
69
|
-
$loog = Loog::Buffer.new
|
70
|
-
f = Fbe.fb.insert
|
71
|
-
f.what = 'hello'
|
72
|
-
f = Fbe.fb.query('(eq what "hello")').each.to_a.first
|
73
|
-
assert_equal([42], f['_job'])
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_increment_id_in_transaction
|
77
|
-
$fb = Factbase.new
|
78
|
-
$global = {}
|
79
|
-
$options = Judges::Options.new
|
80
|
-
$loog = Loog::Buffer.new
|
81
|
-
Fbe.fb.txn do |fbt|
|
82
|
-
fbt.insert
|
83
|
-
fbt.insert
|
84
|
-
end
|
85
|
-
arr = Fbe.fb.query('(always)').each.to_a
|
86
|
-
assert_equal(1, arr[0]._id)
|
87
|
-
assert_equal(2, arr[1]._id)
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_adds_meta_properties
|
91
|
-
$fb = Factbase.new
|
92
|
-
$global = {}
|
93
|
-
$options = Judges::Options.new('JOB_ID' => 42)
|
94
|
-
$loog = Loog::Buffer.new
|
95
|
-
Fbe.fb.insert
|
96
|
-
f = Fbe.fb.query('(always)').each.to_a.first
|
97
|
-
refute_nil(f._id)
|
98
|
-
refute_nil(f._time)
|
99
|
-
refute_nil(f._version)
|
100
|
-
refute_nil(f._job)
|
101
|
-
end
|
102
|
-
end
|
@@ -1,169 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
|
4
|
-
# SPDX-License-Identifier: MIT
|
5
|
-
|
6
|
-
require 'judges/options'
|
7
|
-
require 'loog'
|
8
|
-
require 'webmock/minitest'
|
9
|
-
require_relative '../../lib/fbe/github_graph'
|
10
|
-
require_relative '../test__helper'
|
11
|
-
|
12
|
-
# Test.
|
13
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
14
|
-
# Copyright:: Copyright (c) 2024-2025 Zerocracy
|
15
|
-
# License:: MIT
|
16
|
-
class TestGitHubGraph < Fbe::Test
|
17
|
-
def test_simple_use
|
18
|
-
WebMock.disable_net_connect!
|
19
|
-
global = {}
|
20
|
-
options = Judges::Options.new({ 'testing' => true })
|
21
|
-
Fbe.github_graph(options:, loog: Loog::NULL, global:)
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_simple_use_graph
|
25
|
-
skip("it's a live test, run it manually if you need it")
|
26
|
-
WebMock.allow_net_connect!
|
27
|
-
client = Fbe::Graph.new(token: ENV.fetch('GITHUB_TOKEN', nil))
|
28
|
-
result = client.query(
|
29
|
-
<<~GRAPHQL
|
30
|
-
query {
|
31
|
-
viewer {
|
32
|
-
login
|
33
|
-
}
|
34
|
-
}
|
35
|
-
GRAPHQL
|
36
|
-
)
|
37
|
-
refute_empty(result.viewer.login)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_use_with_global_variables
|
41
|
-
WebMock.disable_net_connect!
|
42
|
-
$global = {}
|
43
|
-
$options = Judges::Options.new({ 'testing' => true })
|
44
|
-
$loog = Loog::NULL
|
45
|
-
Fbe.github_graph
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_with_broken_token
|
49
|
-
skip("it's a live test, run it manually if you need it")
|
50
|
-
WebMock.allow_net_connect!
|
51
|
-
global = {}
|
52
|
-
options = Judges::Options.new({ 'github_token' => 'incorrect-value' })
|
53
|
-
assert_raises(StandardError) { Fbe.github_graph(loog: Loog::NULL, global:, options:) }
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_gets_resolved_conversations
|
57
|
-
skip("it's a live test, run it manually if you need it")
|
58
|
-
WebMock.allow_net_connect!
|
59
|
-
global = {}
|
60
|
-
options = Judges::Options.new
|
61
|
-
g = Fbe.github_graph(options:, loog: Loog::NULL, global:)
|
62
|
-
result = g.resolved_conversations('zerocracy', 'baza', 172)
|
63
|
-
assert_equal(1, result.count)
|
64
|
-
result = g.resolved_conversations('zerocracy', 'baza', 0)
|
65
|
-
assert_instance_of(Array, result)
|
66
|
-
assert_equal(0, result.count)
|
67
|
-
result = g.resolved_conversations('zerocracy1', 'baza', 0)
|
68
|
-
assert_instance_of(Array, result)
|
69
|
-
assert_equal(0, result.count)
|
70
|
-
result = g.resolved_conversations('zerocracy', 'baza1', 0)
|
71
|
-
assert_instance_of(Array, result)
|
72
|
-
assert_equal(0, result.count)
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_gets_resolved_conversations_via_http
|
76
|
-
skip('This test does not work, because the JSON returned is not a valid response from GraphQL')
|
77
|
-
WebMock.disallow_net_connect!
|
78
|
-
global = {}
|
79
|
-
options = Judges::Options.new
|
80
|
-
g = Fbe.github_graph(options:, loog: Loog::NULL, global:)
|
81
|
-
stub_request(:post, 'https://api.github.com/graphql').to_return(
|
82
|
-
body: JSON.pretty_generate(
|
83
|
-
{
|
84
|
-
data: {
|
85
|
-
repository: {
|
86
|
-
name: 'foo'
|
87
|
-
}
|
88
|
-
}
|
89
|
-
}
|
90
|
-
)
|
91
|
-
)
|
92
|
-
result = g.resolved_conversations('foo', 'bar', 42)
|
93
|
-
assert_equal(1, result.count)
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_does_not_count_unresolved_conversations
|
97
|
-
skip("it's a live test, run it manually if you need it")
|
98
|
-
WebMock.allow_net_connect!
|
99
|
-
g = Fbe.github_graph(options: Judges::Options.new, loog: Loog::NULL, global: {})
|
100
|
-
result = g.resolved_conversations('zerocracy', 'judges-action', 296)
|
101
|
-
assert_equal(0, result.count)
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_gets_total_commits_of_repo
|
105
|
-
skip("it's a live test, run it manually if you need it")
|
106
|
-
WebMock.allow_net_connect!
|
107
|
-
global = {}
|
108
|
-
options = Judges::Options.new
|
109
|
-
g = Fbe.github_graph(options:, loog: Loog::NULL, global:)
|
110
|
-
result = g.total_commits('zerocracy', 'baza', 'master')
|
111
|
-
assert_predicate(result, :positive?)
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_get_fake_empty_conversations
|
115
|
-
WebMock.disable_net_connect!
|
116
|
-
graph = Fbe.github_graph(options: Judges::Options.new('testing' => true), loog: Loog::NULL, global: {})
|
117
|
-
result = graph.resolved_conversations(nil, 'baza', 172)
|
118
|
-
assert_empty(result)
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_get_fake_conversations
|
122
|
-
WebMock.disable_net_connect!
|
123
|
-
graph = Fbe.github_graph(options: Judges::Options.new('testing' => true), loog: Loog::NULL, global: {})
|
124
|
-
result = graph.resolved_conversations('zerocracy', 'baza', 172)
|
125
|
-
assert_equal(1, result.count)
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_total_issues_and_pulls
|
129
|
-
WebMock.disable_net_connect!
|
130
|
-
graph = Fbe.github_graph(options: Judges::Options.new('testing' => true), loog: Loog::NULL, global: {})
|
131
|
-
result = graph.total_issues_and_pulls('zerocracy', 'fbe')
|
132
|
-
refute_empty(result)
|
133
|
-
assert_equal(23, result['issues'])
|
134
|
-
assert_equal(19, result['pulls'])
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_fake_total_commits
|
138
|
-
WebMock.disable_net_connect!
|
139
|
-
graph = Fbe.github_graph(options: Judges::Options.new('testing' => true), loog: Loog::NULL, global: {})
|
140
|
-
assert_equal(1484, graph.total_commits('zerocracy', 'fbe', 'master'))
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_fake_issue_type_event
|
144
|
-
WebMock.disable_net_connect!
|
145
|
-
graph = Fbe.github_graph(options: Judges::Options.new('testing' => true), loog: Loog::NULL, global: {})
|
146
|
-
assert_nil(graph.issue_type_event('wrong_id'))
|
147
|
-
add_type_event = graph.issue_type_event('ITAE_examplevq862Ga8lzwAAAAQZanzv')
|
148
|
-
assert_equal('IssueTypeAddedEvent', add_type_event['type'])
|
149
|
-
assert_equal(Time.parse('2025-05-11 18:17:16 UTC'), add_type_event['created_at'])
|
150
|
-
assert_equal('Bug', add_type_event.dig('issue_type', 'name'))
|
151
|
-
assert_nil(add_type_event['prev_issue_type'])
|
152
|
-
assert_equal(526_301, add_type_event.dig('actor', 'id'))
|
153
|
-
assert_equal('yegor256', add_type_event.dig('actor', 'login'))
|
154
|
-
change_type_event = graph.issue_type_event('ITCE_examplevq862Ga8lzwAAAAQZbq9S')
|
155
|
-
assert_equal('IssueTypeChangedEvent', change_type_event['type'])
|
156
|
-
assert_equal(Time.parse('2025-05-11 20:23:13 UTC'), change_type_event['created_at'])
|
157
|
-
assert_equal('Task', change_type_event.dig('issue_type', 'name'))
|
158
|
-
assert_equal('Bug', change_type_event.dig('prev_issue_type', 'name'))
|
159
|
-
assert_equal(526_301, change_type_event.dig('actor', 'id'))
|
160
|
-
assert_equal('yegor256', change_type_event.dig('actor', 'login'))
|
161
|
-
remove_type_event = graph.issue_type_event('ITRE_examplevq862Ga8lzwAAAAQcqceV')
|
162
|
-
assert_equal('IssueTypeRemovedEvent', remove_type_event['type'])
|
163
|
-
assert_equal(Time.parse('2025-05-11 22:09:42 UTC'), remove_type_event['created_at'])
|
164
|
-
assert_equal('Feature', remove_type_event.dig('issue_type', 'name'))
|
165
|
-
assert_nil(remove_type_event['prev_issue_type'])
|
166
|
-
assert_equal(526_301, remove_type_event.dig('actor', 'id'))
|
167
|
-
assert_equal('yegor256', remove_type_event.dig('actor', 'login'))
|
168
|
-
end
|
169
|
-
end
|
data/test/fbe/test_if_absent.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
|
4
|
-
# SPDX-License-Identifier: MIT
|
5
|
-
|
6
|
-
require 'factbase'
|
7
|
-
require 'loog'
|
8
|
-
require 'tmpdir'
|
9
|
-
require_relative '../../lib/fbe/if_absent'
|
10
|
-
require_relative '../test__helper'
|
11
|
-
|
12
|
-
# Test.
|
13
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
14
|
-
# Copyright:: Copyright (c) 2024-2025 Zerocracy
|
15
|
-
# License:: MIT
|
16
|
-
class TestIfAbsent < Fbe::Test
|
17
|
-
def test_ignores
|
18
|
-
fb = Factbase.new
|
19
|
-
fb.insert.foo = 'hello dude'
|
20
|
-
n =
|
21
|
-
Fbe.if_absent(fb:) do |f|
|
22
|
-
f.foo = 'hello dude'
|
23
|
-
end
|
24
|
-
assert_nil(n)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_raises_on_empty_value
|
28
|
-
assert_raises(StandardError) do
|
29
|
-
Fbe.if_absent(fb: Factbase.new) do |f|
|
30
|
-
f.foo = ''
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_raises_on_nil
|
36
|
-
fb = Factbase.new
|
37
|
-
fb.insert.foo = 42
|
38
|
-
assert_raises(StandardError) do
|
39
|
-
Fbe.if_absent(fb: Factbase.new) do |f|
|
40
|
-
f.foo = nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_ignores_with_time
|
46
|
-
fb = Factbase.new
|
47
|
-
t = Time.now
|
48
|
-
fb.insert.foo = t
|
49
|
-
n =
|
50
|
-
Fbe.if_absent(fb:) do |f|
|
51
|
-
f.foo = t
|
52
|
-
end
|
53
|
-
assert_nil(n)
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_injects
|
57
|
-
fb = Factbase.new
|
58
|
-
n =
|
59
|
-
Fbe.if_absent(fb:) do |f|
|
60
|
-
f.foo = 42
|
61
|
-
end
|
62
|
-
assert_equal(42, n.foo)
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_injects_and_reads
|
66
|
-
Fbe.if_absent(fb: Factbase.new) do |f|
|
67
|
-
f.foo = 42
|
68
|
-
assert_equal(42, f.foo)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_complex_ignores
|
73
|
-
fb = Factbase.new
|
74
|
-
f1 = fb.insert
|
75
|
-
f1.foo = 'hello, "dude"!'
|
76
|
-
f1.abc = 42
|
77
|
-
t = Time.now
|
78
|
-
f1.z = t
|
79
|
-
f1.bar = 3.14
|
80
|
-
n =
|
81
|
-
Fbe.if_absent(fb:) do |f|
|
82
|
-
f.foo = 'hello, "dude"!'
|
83
|
-
f.abc = 42
|
84
|
-
f.z = t
|
85
|
-
f.bar = 3.14
|
86
|
-
end
|
87
|
-
assert_nil(n)
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_complex_injects
|
91
|
-
fb = Factbase.new
|
92
|
-
f1 = fb.insert
|
93
|
-
f1.foo = 'hello, dude!'
|
94
|
-
f1.abc = 42
|
95
|
-
t = Time.now
|
96
|
-
f1.z = t
|
97
|
-
f1.bar = 3.14
|
98
|
-
n =
|
99
|
-
Fbe.if_absent(fb:) do |f|
|
100
|
-
f.foo = "hello, \\\"dude\\\" \\' \\' ( \n\n ) (! '"
|
101
|
-
f.abc = 42
|
102
|
-
f.z = t + 1
|
103
|
-
f.bar = 3.15
|
104
|
-
end
|
105
|
-
refute_nil(n)
|
106
|
-
end
|
107
|
-
end
|
data/test/fbe/test_issue.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
|
4
|
-
# SPDX-License-Identifier: MIT
|
5
|
-
|
6
|
-
require 'factbase'
|
7
|
-
require 'judges/options'
|
8
|
-
require 'loog'
|
9
|
-
require_relative '../../lib/fbe/issue'
|
10
|
-
require_relative '../test__helper'
|
11
|
-
|
12
|
-
# Test.
|
13
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
14
|
-
# Copyright:: Copyright (c) 2024-2025 Zerocracy
|
15
|
-
# License:: MIT
|
16
|
-
class TestIssue < Fbe::Test
|
17
|
-
def test_simple
|
18
|
-
fb = Factbase.new
|
19
|
-
f = fb.insert
|
20
|
-
f.repository = 323
|
21
|
-
f.issue = 333
|
22
|
-
global = {}
|
23
|
-
options = Judges::Options.new({ 'testing' => true })
|
24
|
-
assert_equal('yegor256/test#333', Fbe.issue(f, global:, options:, loog: Loog::NULL))
|
25
|
-
end
|
26
|
-
end
|
data/test/fbe/test_iterate.rb
DELETED
@@ -1,253 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
|
4
|
-
# SPDX-License-Identifier: MIT
|
5
|
-
|
6
|
-
require 'factbase'
|
7
|
-
require 'judges/options'
|
8
|
-
require 'loog'
|
9
|
-
require_relative '../../lib/fbe/iterate'
|
10
|
-
require_relative '../test__helper'
|
11
|
-
|
12
|
-
# Test.
|
13
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
14
|
-
# Copyright:: Copyright (c) 2024-2025 Zerocracy
|
15
|
-
# License:: MIT
|
16
|
-
class TestIterate < Fbe::Test
|
17
|
-
def test_simple
|
18
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
19
|
-
fb = Factbase.new
|
20
|
-
fb.insert.foo = 42
|
21
|
-
Fbe.iterate(fb:, loog: Loog::NULL, options: opts, global: {}) do
|
22
|
-
as 'labels-were-scanned'
|
23
|
-
by '(agg (always) (max foo))'
|
24
|
-
repeats 2
|
25
|
-
over do |_repository, foo|
|
26
|
-
f = fb.insert
|
27
|
-
f.foo = foo + 1
|
28
|
-
f.foo
|
29
|
-
end
|
30
|
-
end
|
31
|
-
assert_equal(4, fb.size)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_stops_on_timeout
|
35
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
36
|
-
fb = Factbase.new
|
37
|
-
fb.insert.foo = 42
|
38
|
-
Fbe.iterate(fb:, loog: Loog::NULL, options: opts, global: {}) do
|
39
|
-
as 'labels-were-scanned'
|
40
|
-
by '(agg (always) (max foo))'
|
41
|
-
repeats 2
|
42
|
-
over(timeout: 0.1) do |i|
|
43
|
-
sleep 0.2
|
44
|
-
i
|
45
|
-
end
|
46
|
-
end
|
47
|
-
assert_equal(2, fb.size)
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_many_repeats
|
51
|
-
opts = Judges::Options.new(['repositories=foo/bar,foo/second', 'testing=true'])
|
52
|
-
cycles = 0
|
53
|
-
reps = 5
|
54
|
-
Fbe.iterate(fb: Factbase.new, loog: Loog::NULL, global: {}, options: opts) do
|
55
|
-
as 'labels-were-scanned'
|
56
|
-
by '(plus 1 1)'
|
57
|
-
repeats reps
|
58
|
-
over do |_, nxt|
|
59
|
-
cycles += 1
|
60
|
-
nxt
|
61
|
-
end
|
62
|
-
end
|
63
|
-
assert_equal(reps * 2, cycles)
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_with_restart
|
67
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
68
|
-
cycles = 0
|
69
|
-
fb = Factbase.new
|
70
|
-
f = fb.insert
|
71
|
-
f.foo = 42
|
72
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
73
|
-
as 'labels-were-scanned'
|
74
|
-
by '(agg (and (eq foo 42) (not (exists bar))) (max foo))'
|
75
|
-
repeats 10
|
76
|
-
over do |_, nxt|
|
77
|
-
cycles += 1
|
78
|
-
f.bar = 1
|
79
|
-
nxt
|
80
|
-
end
|
81
|
-
end
|
82
|
-
assert_equal(1, cycles)
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_quota_aware_continues_when_quota_available
|
86
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
87
|
-
fb = Factbase.new
|
88
|
-
cycles = 0
|
89
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
90
|
-
as 'quota-test'
|
91
|
-
by '(plus 1 1)'
|
92
|
-
quota_aware
|
93
|
-
repeats 5
|
94
|
-
over do |_, nxt|
|
95
|
-
cycles += 1
|
96
|
-
nxt + 1
|
97
|
-
end
|
98
|
-
end
|
99
|
-
assert_equal(5, cycles)
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_raises_when_label_not_set
|
103
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
104
|
-
fb = Factbase.new
|
105
|
-
assert_raises(StandardError) do
|
106
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
107
|
-
by '(plus 1 1)'
|
108
|
-
over { |_, nxt| nxt }
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_raises_when_query_not_set
|
114
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
115
|
-
fb = Factbase.new
|
116
|
-
assert_raises(StandardError) do
|
117
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
118
|
-
as 'no-query-test'
|
119
|
-
over { |_, nxt| nxt }
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_raises_when_block_returns_non_integer
|
125
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
126
|
-
fb = Factbase.new
|
127
|
-
assert_raises(StandardError) do
|
128
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
129
|
-
as 'non-integer-test'
|
130
|
-
by '(plus 1 1)'
|
131
|
-
over { |_, _| 'not-an-integer' }
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_raises_when_label_set_twice
|
137
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
138
|
-
fb = Factbase.new
|
139
|
-
assert_raises(StandardError) do
|
140
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
141
|
-
as 'first-label'
|
142
|
-
as 'second-label'
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_raises_when_query_set_twice
|
148
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
149
|
-
fb = Factbase.new
|
150
|
-
assert_raises(StandardError) do
|
151
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
152
|
-
by '(plus 1 1)'
|
153
|
-
by '(plus 2 2)'
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_raises_when_repeats_is_nil
|
159
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
160
|
-
fb = Factbase.new
|
161
|
-
assert_raises(StandardError) do
|
162
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
163
|
-
as 'nil-repeats-test'
|
164
|
-
by '(plus 1 1)'
|
165
|
-
repeats nil
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def test_raises_when_repeats_is_not_positive
|
171
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
172
|
-
fb = Factbase.new
|
173
|
-
assert_raises(StandardError) do
|
174
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
175
|
-
as 'zero-repeats-test'
|
176
|
-
by '(plus 1 1)'
|
177
|
-
repeats 0
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_raises_when_label_is_nil
|
183
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
184
|
-
fb = Factbase.new
|
185
|
-
assert_raises(StandardError) do
|
186
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
187
|
-
as nil
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_raises_when_query_is_nil
|
193
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
194
|
-
fb = Factbase.new
|
195
|
-
assert_raises(StandardError) do
|
196
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
197
|
-
by nil
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
def test_persists_marker_facts
|
203
|
-
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
204
|
-
fb = Factbase.new
|
205
|
-
fb.insert.num = 10
|
206
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
207
|
-
as 'marker-test'
|
208
|
-
by '(agg (always) (max num))'
|
209
|
-
repeats 1
|
210
|
-
over do |_, nxt|
|
211
|
-
nxt + 5
|
212
|
-
end
|
213
|
-
end
|
214
|
-
markers = fb.query("(and (eq what 'marker-test') (eq where 'github'))").each.to_a
|
215
|
-
assert_equal(1, markers.size)
|
216
|
-
assert_equal(15, markers.first.latest)
|
217
|
-
end
|
218
|
-
|
219
|
-
def test_multiple_repositories_with_different_progress
|
220
|
-
opts = Judges::Options.new(['repositories=foo/bar,foo/baz', 'testing=true'])
|
221
|
-
fb = Factbase.new
|
222
|
-
results = []
|
223
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
224
|
-
as 'multi-repo-test'
|
225
|
-
by '(plus 1 1)'
|
226
|
-
repeats 2
|
227
|
-
over do |repo, nxt|
|
228
|
-
results << [repo, nxt]
|
229
|
-
nxt + 1
|
230
|
-
end
|
231
|
-
end
|
232
|
-
assert_equal(4, results.size)
|
233
|
-
end
|
234
|
-
|
235
|
-
def test_all_repos_restart_causes_exit
|
236
|
-
opts = Judges::Options.new(['repositories=foo/bar,foo/baz', 'testing=true'])
|
237
|
-
fb = Factbase.new
|
238
|
-
cycles = 0
|
239
|
-
restarts = 0
|
240
|
-
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
241
|
-
as 'all-restart-test'
|
242
|
-
by '(agg (eq foo 123) (first foo))'
|
243
|
-
repeats 10
|
244
|
-
over do |_, nxt|
|
245
|
-
cycles += 1
|
246
|
-
restarts += 1 if nxt.nil?
|
247
|
-
nxt || 0
|
248
|
-
end
|
249
|
-
end
|
250
|
-
assert_equal(0, cycles)
|
251
|
-
assert_equal(0, restarts)
|
252
|
-
end
|
253
|
-
end
|
data/test/fbe/test_just_one.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
|
4
|
-
# SPDX-License-Identifier: MIT
|
5
|
-
|
6
|
-
require 'factbase'
|
7
|
-
require_relative '../../lib/fbe/just_one'
|
8
|
-
require_relative '../test__helper'
|
9
|
-
|
10
|
-
# Test.
|
11
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
12
|
-
# Copyright:: Copyright (c) 2024-2025 Zerocracy
|
13
|
-
# License:: MIT
|
14
|
-
class TestJustOne < Fbe::Test
|
15
|
-
def test_ignores
|
16
|
-
fb = Factbase.new
|
17
|
-
fb.insert.foo = 'hello dude'
|
18
|
-
n =
|
19
|
-
Fbe.just_one(fb:) do |f|
|
20
|
-
f.foo = 'hello dude'
|
21
|
-
end
|
22
|
-
refute_nil(n)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_injects
|
26
|
-
fb = Factbase.new
|
27
|
-
n =
|
28
|
-
Fbe.just_one(fb:) do |f|
|
29
|
-
f.foo = 42
|
30
|
-
end
|
31
|
-
assert_equal(42, n.foo)
|
32
|
-
end
|
33
|
-
end
|