-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the read method on the return of open_url to actually get the con… #1420
base: main
Are you sure you want to change the base?
Conversation
21bf454
to
cbf9c7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test suite needs to be adjusted accordingly. Currently it assumes OpenURI.open_uri
return a String
but in reality it return a StringIO
or a Tempfile
depending on the response. And both have a read
method.
I am not found of doubles, but something like:
diff --git a/spec/functions/loadjson_spec.rb b/spec/functions/loadjson_spec.rb
index 17d01e45..0022ebfa 100644
--- a/spec/functions/loadjson_spec.rb
+++ b/spec/functions/loadjson_spec.rb
@@ -98,7 +98,9 @@ describe 'loadjson' do
let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' }
it {
- expect(OpenURI).to receive(:open_uri).with(filename, {}).and_return(json)
+ data = double
+ expect(data).to receive(:read).and_return(json)
+ expect(OpenURI).to receive(:open_uri).with(filename, {}).and_return(data)
if Puppet::PUPPETVERSION[0].to_i < 8
expect(PSON).to receive(:load).with(json).and_return(data).once
else
Run bundle exec rake spec
to run the test suite on your machine. Failures are reported here:
./spec/functions/loadjson_spec.rb:100
./spec/functions/loadjson_spec.rb:120
./spec/functions/loadjson_spec.rb:140
./spec/functions/loadjson_spec.rb:157
Yep, will do within a few days, thank you. Do you agree it's a bug though? |
Thanks!
Yup! |
51fdefb
to
fa8339c
Compare
@smortex, I decided to use StringIO in the tests. I'm not sure how to restart the build though. |
Also I see there's no way to test using a docker image, which is a bit of a hassle. Is there a plan to add that similar to other repos of vox pupuli? By the way, why "pupuli" (which is incorrect) and not "populi"? |
@gerases puppetlabs/stdlib uses Litmus to spin up SUTs (systems under test), whereas Vox Pupuli uses Beaker. But as Beaker, Litmus supports Docker (and Podman I think?) Containers for SUTs. I just don't know how to use Litmus. And Vox Pupuli is correct, it's just not 'people', but 'puppet': https://latin-dictionary.net/search/english/puppet |
Oh, fantastic then. Didn't think of "pupulus". Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@bastelfreak Could this be merged? |
I'm a bit hesitant on merging because I don't know if this change breaks the setup for other users. I need to test it and I currently don't have the time. |
I'm surprised I didn't link it, but #1415 was my attempt to address it. |
Summary
Use the read method on the return of open_url to actually get the content. Otherwise the following error is returned by puppetserver: