# # Author:: John Keiser () # Copyright:: Copyright (c) 2013 Opscode, 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 'support/shared/integration/integration_helper' require 'chef/knife/list' require 'chef/knife/delete' require 'chef/knife/show' require 'chef/knife/raw' require 'chef/knife/cookbook_upload' describe 'ChefFSDataStore tests', :workstation do include IntegrationSupport include KnifeSupport let(:cookbook_x_100_metadata_rb) { cb_metadata("x", "1.0.0") } let(:cookbook_z_100_metadata_rb) { cb_metadata("z", "1.0.0") } when_the_repository "has one of each thing" do before do file 'clients/x.json', {} file 'cookbooks/x/metadata.rb', cookbook_x_100_metadata_rb file 'data_bags/x/y.json', {} file 'environments/x.json', {} file 'nodes/x.json', {} file 'roles/x.json', {} file 'users/x.json', {} end context 'GET /TYPE' do it 'knife list -z -R returns everything' do knife('list -z -Rfp /').should_succeed < "x", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}} file 'rolestuff.json', '{"description":"hi there","name":"x"}' file 'cookbooks_to_upload/x/metadata.rb', cookbook_x_100_metadata_rb end it 'knife raw -z -i empty.json -m PUT /clients/x' do knife("raw -z -i #{path_to('empty.json')} -m PUT /clients/x").should_succeed( /"x"/ ) knife('list --local /clients').should_succeed "/clients/x.json\n" end it 'knife cookbook upload works' do knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} x").should_succeed :stderr => < (RUBY_VERSION < "1.9") do knife("raw -z -i #{path_to('rolestuff.json')} -m PUT /roles/x").should_succeed( /"x"/ ) expect(IO.read(path_to('roles/x.json'))).to eq < 'z' } file 'dummynode.json', { "name" => "z", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}} file 'empty_x.json', { 'name' => 'x' } file 'empty_id.json', { 'id' => 'z' } file 'rolestuff.json', '{"description":"hi there","name":"x"}' file 'cookbooks_to_upload/z/metadata.rb', cookbook_z_100_metadata_rb end it 'knife raw -z -i empty.json -m POST /clients' do knife("raw -z -i #{path_to('empty.json')} -m POST /clients").should_succeed( /uri/ ) knife('list --local /clients').should_succeed "/clients/z.json\n" end it 'knife cookbook upload works' do knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} z").should_succeed :stderr => < (RUBY_VERSION < "1.9") do knife("raw -z -i #{path_to('rolestuff.json')} -m POST /roles").should_succeed( /uri/ ) expect(IO.read(path_to('roles/x.json'))).to eq <