diff options
author | Pascal Betz <pascal.betz@gmail.com> | 2016-09-06 21:40:49 +0200 |
---|---|---|
committer | Pascal Betz <pascal.betz@gmail.com> | 2016-09-07 12:16:05 +0200 |
commit | 1112b5a28323bdcee5b7e910575097d1ccb6256c (patch) | |
tree | acd6378f677a3ee7e63ce58662cbfbbebc68e0c0 /spec/helpers | |
parent | 80e575af523f49d314dc83e02989115193b9ab64 (diff) | |
download | gitlab-ce-1112b5a28323bdcee5b7e910575097d1ccb6256c.tar.gz |
Move parsing of sidekiq ps into helper
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/sidekiq_helper_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/helpers/sidekiq_helper_spec.rb b/spec/helpers/sidekiq_helper_spec.rb new file mode 100644 index 00000000000..2eb1c816bc5 --- /dev/null +++ b/spec/helpers/sidekiq_helper_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe SidekiqHelper do + describe 'parse_sidekiq_ps' do + it 'parses line with time' do + line = '55137 10,0 2,1 S+ 2:30pm sidekiq 4.1.4 gitlab [0 of 25 busy] ' + parts = helper.parse_sidekiq_ps(line) + expect(parts).to eq(['55137', '10,0', '2,1', 'S+', '2:30pm', 'sidekiq 4.1.4 gitlab [0 of 25 busy]']) + end + + it 'parses line with date' do + line = '55137 10,0 2,1 S+ Aug 4 sidekiq 4.1.4 gitlab [0 of 25 busy] ' + parts = helper.parse_sidekiq_ps(line) + expect(parts).to eq(['55137', '10,0', '2,1', 'S+', 'Aug 4', 'sidekiq 4.1.4 gitlab [0 of 25 busy]']) + end + + it 'parses line with two digit date' do + line = '55137 10,0 2,1 S+ Aug 04 sidekiq 4.1.4 gitlab [0 of 25 busy] ' + parts = helper.parse_sidekiq_ps(line) + expect(parts).to eq(['55137', '10,0', '2,1', 'S+', 'Aug 04', 'sidekiq 4.1.4 gitlab [0 of 25 busy]']) + end + + it 'parses line with dot as float separator' do + line = '55137 10.0 2.1 S+ 2:30pm sidekiq 4.1.4 gitlab [0 of 25 busy] ' + parts = helper.parse_sidekiq_ps(line) + expect(parts).to eq(['55137', '10.0', '2.1', 'S+', '2:30pm', 'sidekiq 4.1.4 gitlab [0 of 25 busy]']) + end + + it 'does fail gracefully on line not matching the format' do + line = '55137 10.0 2.1 S+ 2:30pm something' + parts = helper.parse_sidekiq_ps(line) + expect(parts).to eq(['?', '?', '?', '?', '?', '?']) + end + end +end |