Sha256: abf2913b58e27af767aa58aa66308c79858d83983e02bbeb080ef33b0b7aae04

Contents?: true

Size: 1.68 KB

Versions: 8

Compression:

Stored size: 1.68 KB

Contents

#!/usr/bin/env rspec
require 'spec_helper'

describe Puppet::Type.type(:group).provider(:groupadd) do
  before do
    described_class.stubs(:command).with(:add).returns '/usr/sbin/groupadd'
    described_class.stubs(:command).with(:delete).returns '/usr/sbin/groupdel'
    described_class.stubs(:command).with(:modify).returns '/usr/sbin/groupmod'
  end

  let(:resource) { Puppet::Type.type(:group).new(:name => 'mygroup', :provider => provider) }
  let(:provider) { described_class.new(:name => 'mygroup') }

  describe "#create" do
    it "should add -o when allowdupe is enabled and the group is being created" do
      resource[:allowdupe] = :true
      provider.expects(:execute).with(['/usr/sbin/groupadd', '-o', 'mygroup'])
      provider.create
    end

    describe "on system that feature system_groups", :if => described_class.system_groups? do
      it "should add -r when system is enabled and the group is being created" do
        resource[:system] = :true
        provider.expects(:execute).with(['/usr/sbin/groupadd', '-r', 'mygroup'])
        provider.create
      end
    end

    describe "on system that do not feature system_groups", :unless => described_class.system_groups? do
      it "should not add -r when system is enabled and the group is being created" do
        resource[:system] = :true
        provider.expects(:execute).with(['/usr/sbin/groupadd', 'mygroup'])
        provider.create
      end
    end
  end

  describe "#gid=" do
    it "should add -o when allowdupe is enabled and the gid is being modified" do
      resource[:allowdupe] = :true
      provider.expects(:execute).with(['/usr/sbin/groupmod', '-g', 150, '-o', 'mygroup'])
      provider.gid = 150
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
puppet-2.7.26 spec/unit/provider/group/groupadd_spec.rb
puppet-2.7.25 spec/unit/provider/group/groupadd_spec.rb
puppet-2.7.24 spec/unit/provider/group/groupadd_spec.rb
puppet-2.7.23 spec/unit/provider/group/groupadd_spec.rb
puppet-2.7.22 spec/unit/provider/group/groupadd_spec.rb
puppet-2.7.21 spec/unit/provider/group/groupadd_spec.rb
puppet-2.7.20 spec/unit/provider/group/groupadd_spec.rb
puppet-2.7.20.rc1 spec/unit/provider/group/groupadd_spec.rb