https://www.puppet.com/community logo
Join Slack
Powered by
# testing
  • h

    Heston Snodgrass

    01/23/2025, 8:09 PM
    they work the same, you just don't assign them to a variable
  • l

    Lumiere

    01/23/2025, 8:09 PM
    right, ruby's return without a keyword syntax 😐
  • l

    Lumiere

    01/23/2025, 8:09 PM
    possibly my least favorite rubyism
  • h

    Heston Snodgrass

    01/23/2025, 8:10 PM
    Copy code
    let(:pre_condition) do
      <<~'EOF'
      something
      something
      EOF
    end
  • h

    Heston Snodgrass

    01/23/2025, 8:11 PM
    yeah, it can be really odd because something is always returned, whether you want it to be or not
  • c

    CVQuesty

    01/23/2025, 8:11 PM
    @bastelfreak's worked. Just needed a comma.
    πŸ‘ 2
  • h

    Heston Snodgrass

    01/23/2025, 8:12 PM
    nice, I didn't know you could pass multiple args to
    include
  • l

    Lumiere

    01/23/2025, 8:12 PM
    I don't ever plan to use it outside testing
  • l

    Lumiere

    01/23/2025, 8:12 PM
    but good to know
  • c

    CVQuesty

    01/23/2025, 8:26 PM
    yeah, that's all I'm doing
  • r

    rnelson0

    01/24/2025, 6:26 PM
    I think you can do
    include $array
    . Why is not clear to me though πŸ˜„
  • d

    David Sandilands

    01/27/2025, 1:35 PM
    We did a role and profile pattern where you could manage classes via hiera to make it slightly less rigid for some customers
    b
    r
    • 3
    • 7
  • r

    ralfbosz

    01/27/2025, 2:41 PM
    Anybody here using beaker with Ubuntu-24 ? The 'run_puppet_install_helper' installs the puppet just fine, but then gives me this error: puppet agent -t Last 10 lines of output were: bash: line 1: puppet: command not found Seems a PATH issue, but when I login manually I can't reproduce it, the $PATH has /opt/puppetlabs/bin
    b
    • 2
    • 10
  • r

    ralfbosz

    01/27/2025, 2:42 PM
    Same beaker with Ubuntu-22 runs just fine, somethings changed in Ubuntu-24 seems
  • t

    TheMeier

    01/28/2025, 8:19 AM
    I have an issue to mock a fact in testing. I am having some code like this in a spec test:
    Copy code
    on_supported_os.each do |os, os_facts|
          context "on #{os}" do
            let(:facts) do
              os_facts.merge(networking: { fqdn: 'my.domain.foo' })
            end
    but
    $facts{'networking']['fqdn']
    always has the value defined in
    spec/default_facts.yml
    b
    y
    h
    • 4
    • 35
  • j

    Joel Wilson

    02/25/2025, 5:38 PM
    Any beaker geniuses in here?
  • b

    bastelfreak

    02/25/2025, 5:43 PM
    "genius" is a bit much
  • b

    bastelfreak

    02/25/2025, 5:43 PM
    but #C0W1Y5VL0 maintains beaker
  • j

    Joel Wilson

    02/25/2025, 5:43 PM
    Trying to add a couple of docker settings like a different network and a bind mount, but can't figure out how to get that into my
    spec_helper_acceptance.rb
  • j

    Joel Wilson

    02/25/2025, 5:43 PM
    So, I should go to that channel?
  • b

    bastelfreak

    02/25/2025, 5:43 PM
    it's worth trying πŸ™‚
  • j

    Joel Wilson

    02/25/2025, 5:43 PM
    Thx.
  • t

    TheMeier

    02/28/2025, 1:35 PM
    in a standard unit test can I access the parameters of the class/defined resource that is currently evaluated?
    y
    h
    • 3
    • 4
  • e

    Ed Rude

    03/11/2025, 10:47 AM
    It’s hard enough to keep modules all up to date without folding in your own changes :)
    πŸ‘ 1
    b
    • 2
    • 1
  • b

    Brian Schonecker

    04/28/2025, 12:36 PM
    I'm dong what couldn't be a more simple test on a class module that does concat. It fails with:
    error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, wrong number of arguments (given 3, expected 1..2)
    The class module (if you can call it that) couldn't be more simple:
    --class manhattan::a {
    concat { '/bin/foo':
    owner => 'root',
    group => 'root',
    mode  => '0755',
    }
    }
    bundle references me to:
    concat/manifests/init.pp, line: 107, column: 27)
    but for the life of me I can't figure out what's going on. The class module passes all other tests. My .fixtures.yml file references:
    concat:
    repo: "<https://github.com/puppetlabs/puppetlabs-concat.git>"
    ref: "v9.0.2"
    The spec file is:
    require 'spec_helper'
    describe 'manhattan::a' do
    it { <http://is_expected.to|is_expected.to> compile }
    end
    It doesn't get much more simple than that. Can anyone shed light on what I might be doing wrong?
    b
    • 2
    • 40
  • b

    bastelfreak

    04/28/2025, 12:38 PM
    IMO the .fixtures.yml should reference the latest branch, not tag
    r
    • 2
    • 1
  • b

    bastelfreak

    04/28/2025, 12:38 PM
    can you show the full error message?
  • y

    Yury Bushmelev

    05/08/2025, 5:40 AM
    JFYI, I spent some time asking qwen.ai about writing unit tests for facts, and it was quite reasonable. At least it was able to answer my question how to mock a
    kernel
    fact value to make my Linux-confined fact unit test to work on MacOS.
  • y

    Yury Bushmelev

    05/08/2025, 5:42 AM
    It even suggested me to use
    Facter.clear
    in
    before :each
    hook, which looks legit but I should recheck the sources/documentation regarding this πŸ€”
  • y

    Yury Bushmelev

    05/08/2025, 5:44 AM
    ah, when asked about details, it told me that was for Facter 2.x.. so now it’s deprecated πŸ˜‚