#85: Feature/use environment without preserve - #86
Conversation
|
Will try to write an integration test and test against my existing repository. (The puppet version was causing some troubles, I'll try and figure out how to make that work). Integration tests don't work locally because I presume |
|
|
||
| def environment | ||
| @options[:preserve_environments] ? @options.fetch(:environment, 'production') : 'production' | ||
| @options.fetch(:environment, 'production') |
There was a problem hiding this comment.
Maybe there should be a protection here to block environment and create-symlinks being used together, as the debug output on 89 states.
There was a problem hiding this comment.
I looked into this and you're actually very close here. There is a method in https://github.com/github/octocatalog-diff/blob/master/lib/octocatalog-diff/catalog/computed.rb#L82-L84 that needs to be updated to match this change. Also some spec tests need to be updated for the new behavior.
Have a look at https://gist.github.com/kpaulisse/7bda51e395aab49585aa9933d78fe724 for what I had to do to get the tests passing. Hopefully this is a push in the right direction - I'm 👍 to the change in general.
|
|
||
| context 'without logger' do | ||
| it 'should install default symlink' do | ||
| it 'should install directory symlink' do |
There was a problem hiding this comment.
This should still say default. Oops.
| # Environment used to compile catalog | ||
| def environment | ||
| @opts[:preserve_environments] ? @opts.fetch(:environment, 'production') : 'production' | ||
| @options.fetch(:environment, 'production') |
|
Will look at those failed tests over the next few days. Haven't checked them yet. But managed to get environment working fully on my own repo so that's good progress. |
|
Hey @homelinen I looked at the test results and this one looks like it might just be a broken test: Basically 2 means "successful, with diffs" and 0 means "successful, no diffs". It looks like you actually changed the original test from 0 to 2 (and I vaguely remember this being in my patch when I first tried your code on my machine but I didn't look into it too deeply at the time). I just re-ran that on my machine and got the same failure as travis is seeing, so if you revert just that one change the test will hopefully pass as it did before. |
kpaulisse
left a comment
There was a problem hiding this comment.
I'm glad to hear this is mostly working for you. I pointed out the test that needs fixing, and made one suggestion about the logger.
Once you have verified code that works for you and let me know you're done, I'll run the updated code within GitHub for a day or so to make sure everything looks good (we end up running this up to 10k times per day in various CI) and then merge. Thanks!
|
|
||
| it 'should exit without error' do | ||
| expect(@result.exitcode).to eq(0), OctocatalogDiff::Integration.format_exception(@result) | ||
| expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result) |
There was a problem hiding this comment.
This one should be reverted as per my earlier comment - change the 2 back to a 0 here.
| context 'with --environment' do | ||
| context 'with logger' do | ||
| it 'should install a symlink to the given environment' do | ||
| logger = double('Logger') |
There was a problem hiding this comment.
The pattern elsewhere in the tests is to actually construct a real logger using:
logger, logger_str = OctocatalogDiff::Spec.setup_logger
You can then also test logger_str.string to be matching text if you want to verify log messages.
I realize that line 127 didn't use this pattern - must have been one I missed when I went through and tried to update all of them long, long ago... Would you mind doing it the new way? 😸
20bfdeb to
ba0e21c
Compare
|
@homelinen the code looks fine now. Are you done with the development here? If so I'll test this internally within GitHub for a couple days, and then merge it. Please advise. |
|
@kpaulisse Yeah, I'm done with the development, I'm happy for internal testing to go ahead. I realise one thing missing is a doc change to the Advanced Environments page. Would you want that in this PR or separate? Happy to work it out either, sorry I forgot about it before. |
|
Feel free to do a separate PR for doc updates. I don't bump version numbers for that. We are testing this version within GitHub today and if all goes well I'll merge it tomorrow. Thanks again! |
…erve Bump version and changelog for #86
Overview
This pull request changes the behaviour of the
--environmentflag when used on its own.Solve the problem described in #85. Allows the
--environmentflag to be used without the--preserve-environmentsflag.Tries to maintain the current functionality by ignoring this parameter when used with
--create-symlinks.Doesn't modify the existing behaviour of
--preserve-environmentsChecklist
rakein your checkout directory, or review the CI job triggered whenever you push to a pull request.rake coverage:specor ignoring untestable sections of code with# :nocovcomments. If you need help getting to 100% coverage please ask; however, don't just submit code with no tests..gemfile into the vendor/cache directory.