fbe 0.0.23 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b13ad3c8a5578c4a9e248948cab63ae21caeea7052d96260f2be85a43ee6f3b8
4
- data.tar.gz: 90f8b081a67be3fd2f94a92cea890abb9b93f9b4b11a37a7bc6502f704c16510
3
+ metadata.gz: 271cf18aec3c0815566d0e437d10e0bed25949388ceadb0249090cefc7018beb
4
+ data.tar.gz: 14e1b474c174ef2a7ee2170b5feae6ddee90f9c9faf789f05f1efe8aaab7427b
5
5
  SHA512:
6
- metadata.gz: 9ea216f0e9be56b06ae8e350ea89b341f9d9fc230ca7785f5b0c0a494fcba3de913143e9c0c5d7074eea3ad368520bfaa462f891c5daf744b4ababbf05e600e8
7
- data.tar.gz: 28c70598550a0e68ad1315fee0adce8ebeb31a7eb400f348181c0f916b3b5aac646a1d4f8d51d79f70e5553f3a4a88b33ba4afd67f2075a735cb578ea5312f0c
6
+ metadata.gz: 5295f5e731076ab568869329a52ecf91289c049e83e22de834c7692302eb19aec6f6bd7fc1e3c2216b0e728620d2a31fd77bc55d091f98cbf036d981bbcdeedb
7
+ data.tar.gz: 7303c455a7f1b244c61bc33b4762383aca458b7f76cc3d9ca11bd6ad0158791c934cf02e8f53b8073b4e2a949b8b98a2685966a815ce3fd846973f74a65984c9
data/Gemfile CHANGED
@@ -32,4 +32,5 @@ gem 'rubocop-performance', '1.21.1', require: false
32
32
  gem 'rubocop-rspec', '3.0.3', require: false
33
33
  gem 'simplecov', '0.22.0', require: false
34
34
  gem 'simplecov-cobertura', '2.1.0', require: false
35
+ gem 'webmock', '3.23.1', require: false
35
36
  gem 'yard', '0.9.36', require: false
data/Gemfile.lock CHANGED
@@ -55,6 +55,9 @@ GEM
55
55
  builder (3.3.0)
56
56
  concurrent-ruby (1.3.3)
57
57
  connection_pool (2.4.1)
58
+ crack (1.0.0)
59
+ bigdecimal
60
+ rexml
58
61
  crass (1.0.6)
59
62
  decoor (0.0.1)
60
63
  diff-lcs (1.5.1)
@@ -87,7 +90,8 @@ GEM
87
90
  ffi (1.17.0-x64-mingw-ucrt)
88
91
  ffi (1.17.0-x86_64-darwin)
89
92
  ffi (1.17.0-x86_64-linux-gnu)
90
- gli (2.21.3)
93
+ gli (2.21.5)
94
+ hashdiff (1.1.0)
91
95
  i18n (1.14.5)
92
96
  concurrent-ruby (~> 1.0)
93
97
  io-console (0.7.2)
@@ -241,6 +245,10 @@ GEM
241
245
  verbose (0.0.2)
242
246
  loog (~> 0.2)
243
247
  tago (~> 0.0)
248
+ webmock (3.23.1)
249
+ addressable (>= 2.8.0)
250
+ crack (>= 0.3.2)
251
+ hashdiff (>= 0.4.0, < 2.0.0)
244
252
  webrick (1.8.1)
245
253
  yaml (0.3.0)
246
254
  yard (0.9.36)
@@ -263,6 +271,7 @@ DEPENDENCIES
263
271
  rubocop-rspec (= 3.0.3)
264
272
  simplecov (= 0.22.0)
265
273
  simplecov-cobertura (= 2.1.0)
274
+ webmock (= 3.23.1)
266
275
  yard (= 0.9.36)
267
276
 
268
277
  BUNDLED WITH
data/lib/fbe/octo.rb CHANGED
@@ -57,9 +57,14 @@ def Fbe.octo(options: $options, global: $global, loog: $loog)
57
57
  }
58
58
  }
59
59
  stack = Faraday::RackBuilder.new do |builder|
60
- builder.use(Faraday::Retry::Middleware)
61
- builder.use(Faraday::HttpCache, serializer: Marshal, shared_cache: false)
60
+ builder.use(
61
+ Faraday::Retry::Middleware,
62
+ exceptions: Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Octokit::TooManyRequests],
63
+ max: 5, interval: 1
64
+ )
65
+ builder.use(Faraday::HttpCache, serializer: Marshal, shared_cache: false, logger: Loog::NULL)
62
66
  builder.use(Octokit::Response::RaiseError)
67
+ builder.use(Faraday::Response::Logger, Loog::NULL)
63
68
  builder.adapter(Faraday.default_adapter)
64
69
  end
65
70
  o.middleware = stack
@@ -137,6 +142,52 @@ class Fbe::FakeOctokit
137
142
  }
138
143
  end
139
144
 
145
+ def repository_workflow_runs(repo)
146
+ {
147
+ total_count: 2,
148
+ workflow_runs: [
149
+ workflow_run(repo, 42),
150
+ workflow_run(repo, 7)
151
+ ]
152
+ }
153
+ end
154
+
155
+ def workflow_run(repo, id)
156
+ {
157
+ id:,
158
+ name: 'copyrights',
159
+ head_branch: 'master',
160
+ head_sha: '7d34c53e6743944dbf6fc729b1066bcbb3b18443',
161
+ event: 'push',
162
+ status: 'completed',
163
+ conclusion: 'success',
164
+ workflow_id: id,
165
+ created_at: random_time,
166
+ repository: repository(repo)
167
+ }
168
+ end
169
+
170
+ def releases(_repo)
171
+ [
172
+ release('https://github...'),
173
+ release('https://gith')
174
+ ]
175
+ end
176
+
177
+ def release(_url)
178
+ {
179
+ node_id: 'RE_kwDOL6GCO84J7Cen',
180
+ tag_name: '0.19.0',
181
+ target_commitish: 'master',
182
+ name: 'just a fake name',
183
+ draft: false,
184
+ prerelease: false,
185
+ created_at: random_time,
186
+ published_at: random_time,
187
+ assets: []
188
+ }
189
+ end
190
+
140
191
  def repository(name)
141
192
  {
142
193
  id: name_to_number(name),
data/lib/fbe.rb CHANGED
@@ -27,5 +27,5 @@
27
27
  # License:: MIT
28
28
  module Fbe
29
29
  # Current version of the gem (changed by .rultor.yml on every release)
30
- VERSION = '0.0.23'
30
+ VERSION = '0.0.25'
31
31
  end
@@ -24,6 +24,7 @@
24
24
 
25
25
  require 'minitest/autorun'
26
26
  require 'judges/options'
27
+ require 'webmock/minitest'
27
28
  require 'loog'
28
29
  require_relative '../test__helper'
29
30
  require_relative '../../lib/fbe/octo'
@@ -54,8 +55,34 @@ class TestOcto < Minitest::Test
54
55
  assert_equal(100, o.rate_limit.remaining)
55
56
  end
56
57
 
58
+ def test_caching
59
+ WebMock.disable_net_connect!
60
+ global = {}
61
+ o = Fbe.octo(loog: Loog::NULL, global:, options: Judges::Options.new)
62
+ stub_request(:get, 'https://api.github.com/users/yegor256')
63
+ .to_return(status: 200, body: '{}', headers: { 'Cache-Control' => 'public, max-age=60', 'etag' => 'abc' })
64
+ .times(1)
65
+ .then
66
+ .to_raise('second request should be cached, not passed to GitHub API!')
67
+ o.user('yegor256')
68
+ o.user('yegor256')
69
+ end
70
+
71
+ def test_retrying
72
+ WebMock.disable_net_connect!
73
+ global = {}
74
+ o = Fbe.octo(loog: Loog::NULL, global:, options: Judges::Options.new)
75
+ stub_request(:get, 'https://api.github.com/users/yegor256')
76
+ .to_raise(Octokit::TooManyRequests.new)
77
+ .times(1)
78
+ .then
79
+ .to_return(status: 200, body: '{}')
80
+ o.user('yegor256')
81
+ end
82
+
57
83
  def test_with_broken_token
58
84
  skip # it's a "live" test, run it manually if you need it
85
+ WebMock.enable_net_connect!
59
86
  global = {}
60
87
  options = Judges::Options.new({ 'github_token' => 'incorrect-value' })
61
88
  o = Fbe.octo(loog: Loog::NULL, global:, options:)
@@ -64,6 +91,7 @@ class TestOcto < Minitest::Test
64
91
 
65
92
  def test_commit_pulls
66
93
  skip # it's a "live" test, run it manually if you need it
94
+ WebMock.enable_net_connect!
67
95
  o = Fbe.octo(loog: Loog::NULL, global: {}, options: Judges::Options.new)
68
96
  assert_equal(1, o.commit_pulls('zerocracy/fbe', '0b7d0699bd744b62c0731064c2adaad0c58e1416').size)
69
97
  assert_equal(0, o.commit_pulls('zerocracy/fbe', '16b3ea6b71c6e932ba7666c40ca846ecaa6d6f0d').size)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko