File: gnu_spec.rb

package info (click to toggle)
puppet-agent 8.10.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 27,392 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (27 lines) | stat: -rw-r--r-- 1,393 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'spec_helper'
require 'puppet/module_tool'

describe Puppet::ModuleTool::Tar::Gnu, unless: Puppet::Util::Platform.windows? do
  let(:sourcedir)  { '/space path/the/src/dir' }
  let(:sourcefile) { '/space path/the/module.tar.gz' }
  let(:destdir)    { '/space path/the/dest/dir' }
  let(:destfile)   { '/space path/the/dest/fi le.tar.gz' }

  let(:safe_sourcedir)  { '/space\ path/the/src/dir' }
  let(:safe_sourcefile) { '/space\ path/the/module.tar.gz' }
  let(:safe_destdir)    { '/space\ path/the/dest/dir' }
  let(:safe_destfile)   { 'fi\ le.tar.gz' }

  it "unpacks a tar file" do
    expect(Puppet::Util::Execution).to receive(:execute).with("gzip -dc #{safe_sourcefile} | tar --extract --no-same-owner --directory #{safe_destdir} --file -")
    expect(Puppet::Util::Execution).to receive(:execute).with(['find', destdir, '-type', 'd', '-exec', 'chmod', '755', '{}', '+'])
    expect(Puppet::Util::Execution).to receive(:execute).with(['find', destdir, '-type', 'f', '-exec', 'chmod', 'u+rw,g+r,a-st', '{}', '+'])
    expect(Puppet::Util::Execution).to receive(:execute).with(['chown', '-R', '<owner:group>', destdir])
    subject.unpack(sourcefile, destdir, '<owner:group>')
  end

  it "packs a tar file" do
    expect(Puppet::Util::Execution).to receive(:execute).with("tar cf - #{safe_sourcedir} | gzip -c > #{safe_destfile}")
    subject.pack(sourcedir, destfile)
  end
end