https://www.puppet.com/community logo
Join Slack
Powered by
# voxpupuli
  • y

    Yury Bushmelev

    05/05/2023, 12:12 PM
    I’d say I know some tricks.. but have no clear understanding how it works in details 🙂 let me have a look
  • b

    bastelfreak

    05/05/2023, 12:12 PM
    because we don't mock ENV.fetch: https://github.com/voxpupuli/beaker-puppet/pull/220/files#diff-7612e8b330ceb1b2d78e89b0bef12e857228f13d8804975163c5855d678318a1R58
  • y

    Yury Bushmelev

    05/05/2023, 12:15 PM
    I’d say we should mock it then
  • y

    Yury Bushmelev

    05/05/2023, 12:17 PM
    or even better.. those defaults should be default values of a function parameters
  • y

    Yury Bushmelev

    05/05/2023, 12:17 PM
    so it’ll use variables if no params passed
  • b

    bastelfreak

    05/05/2023, 12:17 PM
    I'm open for patches 😄
  • b

    bastelfreak

    05/05/2023, 12:17 PM
    not sure how to mock that properly
  • y

    Yury Bushmelev

    05/05/2023, 12:18 PM
    Copy code
    allow(ENV).to receive(:[]) # stub a default value first if message might be received with other args as well.
       allow(ENV).to receive(:[]).with(name).and_return(value)
  • y

    Yury Bushmelev

    05/05/2023, 12:18 PM
    quick googling/stackoverflowing (I’m too old for ChatGPT)
    😁 1
  • v

    VoxBot

    05/05/2023, 12:20 PM
    https://rspec.info/features/3-12/rspec-mocks/ may help
  • y

    Yury Bushmelev

    05/05/2023, 12:20 PM
    https://github.com/voxpupuli/beaker-puppet/blob/f0ce27306945c4d60e4383f03971a598e17df6d9/spec/beaker-puppet/install_utils/foss_utils_spec.rb#L207 As I see [] is mocked.. so you should add the same but for
    receive(:fetch)
    .. and maybe drop
    []
    at all if only fetch is used now
  • v

    VoxBot

    05/05/2023, 12:21 PM
    indeed, though I wonder how useful the ENV.fetch cop really is
  • y

    Yury Bushmelev

    05/05/2023, 12:21 PM
    the only profit is default value as I see
  • v

    VoxBot

    05/05/2023, 12:21 PM
    no, it also raises an error if the var is not set
  • y

    Yury Bushmelev

    05/05/2023, 12:21 PM
    ah, well..
  • v

    VoxBot

    05/05/2023, 12:21 PM
    so ENV.fetch('bla') will fail if bla is not set
  • y

    Yury Bushmelev

    05/05/2023, 12:22 PM
    not a big deal if you’re ok with nil in the end
  • y

    Yury Bushmelev

    05/05/2023, 12:23 PM
    though I’d move picking the env vars values as defaults to the function parameters (where those are nil by default)
  • y

    Yury Bushmelev

    05/05/2023, 12:23 PM
    I believe there is no reason to test ENV.fetch() 🙂
  • v

    VoxBot

    05/05/2023, 12:24 PM
    yes, it can certainly be better to have defaults specified with fetch
  • v

    VoxBot

    05/05/2023, 12:30 PM
    so should we stick with ENV?
  • v

    VoxBot

    05/05/2023, 12:35 PM
    updated it to stick with ENV
  • v

    VoxBot

    05/05/2023, 12:45 PM
    and https://github.com/voxpupuli/beaker/pull/1813 please
  • v

    VoxBot

    05/05/2023, 12:47 PM
    argh, I missed that one? I earlier had it in https://github.com/voxpupuli/beaker/pull/1762 but missed it
  • v

    VoxBot

    05/05/2023, 12:48 PM
    this is a backport to 4.x. it's fixed already in master/in the 5.x releases
  • v

    VoxBot

    05/05/2023, 12:49 PM
    ah - still, I expected it to be in that PR
  • v

    VoxBot

    05/05/2023, 12:49 PM
    ah okay
  • v

    VoxBot

    05/05/2023, 12:52 PM
    https://github.com/voxpupuli/beaker/pull/1814 and https://github.com/voxpupuli/beaker-puppet/pull/220 are ready
  • v

    VoxBot

    05/05/2023, 1:34 PM
    and the last rubocop change: https://github.com/voxpupuli/beaker-puppet/pull/221
  • v

    VoxBot

    05/05/2023, 2:18 PM
    can I get a review for https://github.com/voxpupuli/beaker-docker/pull/118 and https://github.com/voxpupuli/beaker-docker/pull/117
1...463464465...640Latest