mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Discard/skip empty tags
This commit is contained in:
parent
b6cb20ba9f
commit
3aa8389749
2 changed files with 11 additions and 0 deletions
|
|
@ -499,6 +499,8 @@ module Vmpooler
|
|||
arg[tag] = arg[tag].match(filter).captures.join if arg[tag].match(filter)
|
||||
end
|
||||
|
||||
next if arg[tag].nil? or arg[tag].empty?
|
||||
|
||||
backend.hset('vmpooler__vm__' + params[:hostname], 'tag:' + tag, arg[tag])
|
||||
backend.hset('vmpooler__tag__' + Date.today.to_s, params[:hostname] + ':' + tag, arg[tag])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -323,6 +323,15 @@ describe Vmpooler::API::V1 do
|
|||
expect(last_response.status).to eq(200)
|
||||
end
|
||||
|
||||
it 'skips empty tags' do
|
||||
put "#{prefix}/vm/testhost", '{"tags":{"tested_by":""}}'
|
||||
|
||||
expect(last_response).to be_ok
|
||||
expect(last_response.header['Content-Type']).to eq('application/json')
|
||||
expect(last_response.body).to eq(JSON.pretty_generate({'ok' => true}))
|
||||
expect(last_response.status).to eq(200)
|
||||
end
|
||||
|
||||
it 'does not set tags if request body format is invalid' do
|
||||
put "#{prefix}/vm/testhost", '{"tags":{"tested"}}'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue