-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return hash instead of array from API function
- Loading branch information
1 parent
2b20fab
commit d57711e
Showing
6 changed files
with
66 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -314,16 +314,17 @@ | |
) | ||
end | ||
|
||
context 'and returns 200' do | ||
context 'without data' do | ||
context 'and queries successfully' do | ||
context 'with no return entries' do | ||
let(:pre_condition) do | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { return [200, undef] }' | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { | ||
return { content => [] } | ||
}' | ||
end | ||
|
||
users_allow_api_nodata_content = <<-END.gsub(%r{^\s+\|}, '') | ||
|# This file is being maintained by Puppet. | ||
|# DO NOT EDIT | ||
| | ||
END | ||
|
||
it { | ||
|
@@ -344,7 +345,6 @@ | |
|# DO NOT EDIT | ||
|[email protected] | ||
|[email protected] | ||
| | ||
END | ||
|
||
it { | ||
|
@@ -353,9 +353,11 @@ | |
end | ||
end | ||
|
||
context 'with data' do | ||
context 'with it returning "[email protected]"' do | ||
let(:pre_condition) do | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { return [200, \'[email protected]\'] }' | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { | ||
return { content => ["[email protected]"]} | ||
}' | ||
end | ||
|
||
users_allow_api_data_content = <<-END.gsub(%r{^\s+\|}, '') | ||
|
@@ -392,9 +394,11 @@ | |
end | ||
end | ||
|
||
context 'and return non-200 code' do | ||
context 'and queries fails' do | ||
let(:pre_condition) do | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { return [0, undef] }' | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { | ||
return { error => ["https://host.domain.tld returns HTTP code: 502"] } | ||
}' | ||
end | ||
|
||
it { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -918,11 +918,13 @@ | |
} | ||
end | ||
let(:pre_condition) do | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { return [200, undef] }' | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { | ||
return { content => [] } | ||
}' | ||
end | ||
|
||
it do | ||
is_expected.to contain_file('vas_users_allow').with_content(header + "\n") | ||
is_expected.to contain_file('vas_users_allow').with_content(header) | ||
end | ||
end | ||
|
||
|
@@ -935,7 +937,9 @@ | |
} | ||
end | ||
let(:pre_condition) do | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { return [200, \'[email protected]\'] }' | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { | ||
return { content => ["[email protected]"] } | ||
}' | ||
end | ||
|
||
it do | ||
|
@@ -953,11 +957,13 @@ | |
} | ||
end | ||
let(:pre_condition) do | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { return [200, undef] }' | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { | ||
return { content => [] } | ||
}' | ||
end | ||
|
||
it do | ||
is_expected.to contain_file('vas_users_allow').with_content(header + "[email protected]\n[email protected]\n\n") | ||
is_expected.to contain_file('vas_users_allow').with_content(header + "[email protected]\n[email protected]\n") | ||
end | ||
end | ||
|
||
|
@@ -971,7 +977,9 @@ | |
} | ||
end | ||
let(:pre_condition) do | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { return [200, \'[email protected]\'] }' | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { | ||
return { content => ["[email protected]"] } | ||
}' | ||
end | ||
|
||
it do | ||
|
@@ -1007,11 +1015,13 @@ | |
} | ||
end | ||
let(:pre_condition) do | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { return [200, undef] }' | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { | ||
return { content => [] } | ||
}' | ||
end | ||
|
||
it do | ||
is_expected.to contain_file('vas_users_allow').with_content(header + "\n") | ||
is_expected.to contain_file('vas_users_allow').with_content(header) | ||
end | ||
end | ||
|
||
|
@@ -1024,7 +1034,9 @@ | |
} | ||
end | ||
let(:pre_condition) do | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { return [200, \'[email protected]\'] }' | ||
'function vas::api_fetch($api_users_allow_url, $api_token, $api_ssl_verify) { | ||
return { content => "[email protected]" } | ||
}' | ||
end | ||
|
||
it do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters