<commit_before>#
# 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/data_collector"
require "socket"

#
# FIXME FIXME FIXME:  What we need to do here is have the ability to construct a real resource collection
# with some test resources that will correctly be up-to-date/updated/skipped/failed/unprocessed and really
# converge a client with them (sort of chefspec-like construction of a Chef::Client but with the actions
# actually running -- another testing requirement similar to the integration testing framework in cheffish as well)
#
describe Chef::DataCollector do
  before(:each) do
    Chef::Config[:enable_reporting] = true
  end

  let(:node) { Chef::Node.new }

  let(:rest_client) { double("Chef::ServerAPI (mock)") }

  let(:data_collector) { Chef::DataCollector::Reporter.new(events) }

  let(:new_resource) do
    new_resource = Chef::Resource::File.new("/tmp/a-file.txt")
    new_resource.checksum nil
    # This next line is a hack to work around the fact that the name property will not have been autovivified yet
    # in these unit tests which breaks some assumptions.  Really the Formatters::ErrorMapper.resource_failed and
    # related APIs need to properly walk and get properties on the resource rather than walking through instance
    # variables, but the ErrorMappers probably pre-date the conversion to properties.  But this next line is necesary
    # to populate the name_property instance variable (which will happen naturally during the course of running the
    # provider, so I don't think this is a user-visibile bug).
    new_resource.path
    new_resource
  end

  let(:current_resource) do
    current_resource = Chef::Resource::File.new("/tmp/a-file.txt")
    current_resource.checksum "1234123412341234123412341234123412341234123412341234123412341234"
    current_resource<commit_msg>Remove unncessary test state.<commit_after>#
# 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/data_collector"
require "socket"

#
# FIXME FIXME FIXME:  What we need to do here is have the ability to construct a real resource collection
# with some test resources that will correctly be up-to-date/updated/skipped/failed/unprocessed and really
# converge a client with them (sort of chefspec-like construction of a Chef::Client but with the actions
# actually running -- another testing requirement similar to the integration testing framework in cheffish as well)
#
describe Chef::DataCollector do
  let(:node) { Chef::Node.new }

  let(:rest_client) { double("Chef::ServerAPI (mock)") }

  let(:data_collector) { Chef::DataCollector::Reporter.new(events) }

  let(:new_resource) do
    new_resource = Chef::Resource::File.new("/tmp/a-file.txt")
    new_resource.checksum nil
    # This next line is a hack to work around the fact that the name property will not have been autovivified yet
    # in these unit tests which breaks some assumptions.  Really the Formatters::ErrorMapper.resource_failed and
    # related APIs need to properly walk and get properties on the resource rather than walking through instance
    # variables, but the ErrorMappers probably pre-date the conversion to properties.  But this next line is necesary
    # to populate the name_property instance variable (which will happen naturally during the course of running the
    # provider, so I don't think this is a user-visibile bug).
    new_resource.path
    new_resource
  end

  let(:current_resource) do
    current_resource = Chef::Resource::File.new("/tmp/a-file.txt")
    current_resource.checksum "1234123412341234123412341234123412341234123412341234123412341234"
    current_resource
{'fraction_non_alphanumeric': 0.0731253873166701, 'fraction_numerical': 0.028919644701507954, 'mean_word_length': 4.47737556561086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5878476', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1261, 'n_words': 557}