spec test domain set at the config and provider levels

This commit is contained in:
Samuel Beaulieu 2022-03-29 13:32:23 -05:00
parent 70b5bd297a
commit 2e608b7196
No known key found for this signature in database
GPG key ID: 12030F74136D0F34

View file

@ -37,7 +37,12 @@ describe Vmpooler::API::V2 do
'poolone' => ['pool1'], 'poolone' => ['pool1'],
'pool2' => ['pool1'] 'pool2' => ['pool1']
}, },
pool_names: [ 'pool1', 'pool2', 'pool3', 'poolone' ] pool_names: [ 'pool1', 'pool2', 'pool3', 'poolone' ],
providers: {
:dummy => {
'domain' => 'dummy.com'
}
}
} }
} }
let(:current_time) { Time.now } let(:current_time) { Time.now }
@ -116,7 +121,6 @@ describe Vmpooler::API::V2 do
let(:domain) { 'example.com' } let(:domain) { 'example.com' }
before(:each) do before(:each) do
config[:config]['domain'] = domain config[:config]['domain'] = domain
config[:pools][0]['domain'] = domain
end end
it 'should include domain in the return reply' do it 'should include domain in the return reply' do
@ -275,7 +279,7 @@ describe Vmpooler::API::V2 do
config[:config]['domain'] = domain config[:config]['domain'] = domain
end end
it 'should include the domain in the result' do it 'should include the domain in the hostname as fqdn, not a separate key unlike in v1' do
get "#{prefix}/ondemandvm/#{uuid}" get "#{prefix}/ondemandvm/#{uuid}"
expected = { expected = {
"ok": true, "ok": true,
@ -283,10 +287,31 @@ describe Vmpooler::API::V2 do
"ready": true, "ready": true,
"pool1": { "pool1": {
"hostname": [ "hostname": [
vmname "#{vmname}.#{domain}"
] ]
}, }
"domain": domain }
expect(last_response.body).to eq(JSON.pretty_generate(expected))
end
end
context 'with domain set in the provider' do
let(:domain) { 'dummy.com' }
before(:each) do
config[:pools][0]['provider'] = 'dummy'
end
it 'should include the domain in the hostname as fqdn, not a separate key unlike in v1' do
get "#{prefix}/ondemandvm/#{uuid}"
expected = {
"ok": true,
"request_id": uuid,
"ready": true,
"pool1": {
"hostname": [
"#{vmname}.#{domain}"
]
}
} }
expect(last_response.body).to eq(JSON.pretty_generate(expected)) expect(last_response.body).to eq(JSON.pretty_generate(expected))
end end