Sha256: 7af1b69d2a52a4630bbe943216b615e5bc971ac03bf27ae24ea650fa765e96a7

Contents?: true

Size: 1.8 KB

Versions: 16

Compression:

Stored size: 1.8 KB

Contents

require "spec_helper"

module Omnibus
  describe Compressor::TGZ do
    let(:project) do
      Project.new.tap do |project|
        project.name("project")
        project.homepage("https://example.com")
        project.install_dir("/opt/project")
        project.build_version("1.2.3")
        project.build_iteration("2")
        project.maintainer("Chef Software")
      end
    end

    subject { described_class.new(project) }

    let(:project_root) { File.join(tmp_path, "project/root") }
    let(:package_dir)  { File.join(tmp_path, "package/dir") }
    let(:staging_dir)  { File.join(tmp_path, "staging/dir") }

    before do
      create_directory(project_root)
      create_directory(package_dir)
      create_directory(staging_dir)

      allow(project).to receive(:packagers_for_system)
        .and_return([Packager::PKG.new(project)])

      Config.project_root(project_root)
      Config.package_dir(package_dir)

      allow(subject).to receive(:staging_dir)
        .and_return(staging_dir)

      allow(subject).to receive(:shellout!)
    end

    describe "#package_name" do
      it "returns the name of the packager" do
        expect(subject.package_name).to eq("project-1.2.3-2.pkg.tar.gz")
      end
    end

    describe "#write_tgz" do
      before do
        File.open("#{staging_dir}/project-1.2.3-2.pkg", "wb") do |f|
          f.write " " * 1_000_000
        end
      end

      it "generates the file" do
        subject.write_tgz
        expect("#{staging_dir}/project-1.2.3-2.pkg.tar.gz").to be_a_file
      end

      it "has the correct content" do
        subject.write_tgz
        file = File.open("#{staging_dir}/project-1.2.3-2.pkg.tar.gz", "rb")
        contents = file.read
        file.close

        expect(contents).to include("\x1F\x8B\b\x00".force_encoding("ASCII-8BIT"))
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
omnibus-8.0.15 spec/unit/compressors/tgz_spec.rb
omnibus-8.0.9 spec/unit/compressors/tgz_spec.rb
omnibus-7.0.34 spec/unit/compressors/tgz_spec.rb
omnibus-7.0.13 spec/unit/compressors/tgz_spec.rb
omnibus-7.0.12 spec/unit/compressors/tgz_spec.rb
omnibus-6.1.9 spec/unit/compressors/tgz_spec.rb
omnibus-6.1.7 spec/unit/compressors/tgz_spec.rb
omnibus-6.1.4 spec/unit/compressors/tgz_spec.rb
omnibus-6.0.30 spec/unit/compressors/tgz_spec.rb
omnibus-6.0.25 spec/unit/compressors/tgz_spec.rb
omnibus-6.0.24 spec/unit/compressors/tgz_spec.rb
omnibus-6.0.1 spec/unit/compressors/tgz_spec.rb
omnibus-5.6.8 spec/unit/compressors/tgz_spec.rb
omnibus-5.6.6 spec/unit/compressors/tgz_spec.rb
omnibus-5.6.1 spec/unit/compressors/tgz_spec.rb
omnibus-5.6.0 spec/unit/compressors/tgz_spec.rb