codecov 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/codecov.rb +6 -4
  3. data/test/test_codecov.rb +24 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: daba8db072c6615d0e1715680a1753b8e8edf9d8c587674acf22d92edceec613
4
- data.tar.gz: e139f061377a88e8a7266db95acd9354b20f81885e49c2d070c8075a13c701d4
3
+ metadata.gz: b59d7f1fb16986a207023da3b8f2130b4014084cf7d73d688c304e761c683513
4
+ data.tar.gz: 68ba0cc7cd7cc16d84e88dd2bf20db83f69872eb540de4e9d4128ec0e889888f
5
5
  SHA512:
6
- metadata.gz: 8a9ab0aee0e4c10821f6663b6f6577fba04f0408cbc1e76a55beb7d7113a07c6cbb2951c3ba88c9eb65af0f8599c1414caaa4b89f853c82441a21db0d37bd099
7
- data.tar.gz: 51f0f8a2ebf765daa5687b2337db53c3a5a2aaf086a307629f5f463a4d3b435f6e3586586059def772ede349c2d2eb8273c2e967eb9a14be01c432098d31b1fc
6
+ metadata.gz: c636171303865424027efcfe53b8de75a1b860dc21f70bc43b65d11ea81eb6c1805c4d7a49ab650e7a0dbda992bdfd78e72aa2c6fd881f8d983859bde850ca80
7
+ data.tar.gz: b9fc5e08981827a1dc873410222e7590baa41d8c8ba7563803edb35e29d9d2fd2b307a1a3ef85f7893bfd93ef27e79541e419c5cb6842b2ca7564663790a928e
@@ -8,7 +8,7 @@ require 'colorize'
8
8
  require 'zlib'
9
9
 
10
10
  class SimpleCov::Formatter::Codecov
11
- VERSION = '0.2.2'
11
+ VERSION = '0.2.3'
12
12
 
13
13
  ### CIs
14
14
  RECOGNIZED_CIS = [
@@ -315,10 +315,12 @@ class SimpleCov::Formatter::Codecov
315
315
  def gzip_report(report)
316
316
  puts ['==>'.green, 'Gzipping contents'].join(' ')
317
317
 
318
- gzip = Zlib::GzipWriter.new(StringIO.new)
318
+ io = StringIO.new
319
+ gzip = Zlib::GzipWriter.new(io)
319
320
  gzip << report
321
+ gzip.close
320
322
 
321
- gzip.close.string
323
+ io.string
322
324
  end
323
325
 
324
326
  def upload_to_codecov(ci, report)
@@ -352,7 +354,7 @@ class SimpleCov::Formatter::Codecov
352
354
  https.use_ssl = !url.match(/^https/).nil?
353
355
 
354
356
  puts ['-> '.green, 'Pinging Codecov'].join(' ')
355
- puts "#{url}/#{uri.path}?#{query_without_token}"
357
+ puts "#{url}#{uri.path}?#{query_without_token}"
356
358
 
357
359
  req = Net::HTTP::Post.new(
358
360
  "#{uri.path}?#{query}",
@@ -39,15 +39,31 @@ class TestCodecov < Minitest::Test
39
39
  stub_file('/path/lib/somefile.rb', [1, nil, 1, 1, 1, 0, 0, nil, 1, nil])
40
40
  ])
41
41
  SimpleCov.stubs(:root).returns('/path')
42
- data = formatter.format(result)
42
+ success_stubs if success
43
+ data = formatter.format(result, false)
43
44
  puts data
44
45
  puts data['params']
45
46
  if success
46
47
  assert_successful_upload(data)
47
48
  end
49
+ WebMock.reset!
48
50
  data
49
51
  end
50
52
 
53
+ def success_stubs
54
+ stub_request(:post, %r{https:\/\/codecov.io\/upload})
55
+ .to_return(
56
+ status: 200,
57
+ body: "https://codecov.io/gh/fake\n" \
58
+ 'https://storage.googleapis.com/codecov/fake'
59
+ )
60
+ stub_request(:put, %r{https:\/\/storage.googleapis.com\/})
61
+ .to_return(
62
+ status: 200,
63
+ body: ''
64
+ )
65
+ end
66
+
51
67
  def assert_successful_upload(data)
52
68
  assert_equal(data['result']['uploaded'], true)
53
69
  assert_equal(data['result']['message'], 'Coverage reports upload successfully')
@@ -521,6 +537,13 @@ class TestCodecov < Minitest::Test
521
537
  end
522
538
 
523
539
  def test_invalid_token
540
+ stub_request(:post, %r{https:\/\/codecov.io\/upload})
541
+ .to_return(
542
+ status: 400,
543
+ body: "HTTP 400\n" \
544
+ 'Provided token is not a UUID.'
545
+ )
546
+
524
547
  ENV['CODECOV_TOKEN'] = 'fake'
525
548
  result = upload(false)
526
549
  assert_equal(false, result['result']['uploaded'])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codecov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - codecov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-17 00:00:00.000000000 Z
11
+ date: 2020-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize