Sha256: 3e25f1c1fa7c327e3769bcefccbb5c751f1958f7b92a6ed5f9b33f2feeffb065

Contents?: true

Size: 1.61 KB

Versions: 136

Compression:

Stored size: 1.61 KB

Contents

#
# Author:: Adam Jacob (<adam@chef.io>)
# Copyright:: Copyright (c) Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require "spec_helper"
require "chef/mixin/checksum"
require "stringio"

class Chef::CMCCheck
  include Chef::Mixin::Checksum
end

describe Chef::Mixin::Checksum do
  before(:each) do
    @checksum_user = Chef::CMCCheck.new
    @cache = Chef::Digester.instance
    @file = CHEF_SPEC_DATA + "/checksum/random.txt"
    @stat = double("File::Stat", { mtime: Time.at(0) })
    allow(File).to receive(:stat).and_return(@stat)
  end

  it "gets the checksum of a file" do
    expect(@checksum_user.checksum(@file)).to eq("09ee9c8cc70501763563bcf9c218d71b2fbf4186bf8e1e0da07f0f42c80a3394")
  end

  describe "short_cksum" do
    context "nil provided for checksum" do
      it "returns none" do
        expect(@checksum_user.short_cksum(nil)).to eq("none")
      end
    end

    context "non-nil provided for checksum" do
      it "returns the short checksum" do
        expect(@checksum_user.short_cksum("u7ghbxikk3i9blsimmy2y2ionmxx")).to eq("u7ghbx")
      end
    end
  end

end

Version data entries

136 entries across 136 versions & 1 rubygems

Version Path
chef-18.0.169-x64-mingw-ucrt spec/unit/mixin/checksum_spec.rb
chef-18.0.169 spec/unit/mixin/checksum_spec.rb
chef-16.18.0-universal-mingw32 spec/unit/mixin/checksum_spec.rb
chef-16.18.0 spec/unit/mixin/checksum_spec.rb
chef-17.10.0-universal-mingw32 spec/unit/mixin/checksum_spec.rb
chef-17.10.0 spec/unit/mixin/checksum_spec.rb
chef-17.9.52-universal-mingw32 spec/unit/mixin/checksum_spec.rb
chef-17.9.52 spec/unit/mixin/checksum_spec.rb
chef-16.17.51-universal-mingw32 spec/unit/mixin/checksum_spec.rb
chef-16.17.51 spec/unit/mixin/checksum_spec.rb
chef-17.9.46-universal-mingw32 spec/unit/mixin/checksum_spec.rb
chef-17.9.46 spec/unit/mixin/checksum_spec.rb
chef-17.9.42-universal-mingw32 spec/unit/mixin/checksum_spec.rb
chef-17.9.42 spec/unit/mixin/checksum_spec.rb
chef-16.17.39-universal-mingw32 spec/unit/mixin/checksum_spec.rb
chef-16.17.39 spec/unit/mixin/checksum_spec.rb
chef-17.9.26-universal-mingw32 spec/unit/mixin/checksum_spec.rb
chef-17.9.26 spec/unit/mixin/checksum_spec.rb
chef-17.9.18-universal-mingw32 spec/unit/mixin/checksum_spec.rb
chef-17.9.18 spec/unit/mixin/checksum_spec.rb