Skip to content

Commit 251174c

Browse files
author
AJ Christensen
committed
CHEF-151: Indexer specs, tweak default config files
Set default config files for all applications.
1 parent 0fae40c commit 251174c

6 files changed

Lines changed: 63 additions & 5 deletions

File tree

chef-server/bin/chef-indexer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
$: << File.join(File.dirname(__FILE__), "..", "lib")
2222

2323
require 'rubygems'
24-
require 'chef/application/Indexer'
24+
require 'chef/application/indexer'
2525

2626
Chef::Application::Indexer.new.run

chef/lib/chef/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def run
5757
def configure_chef
5858
parse_options
5959

60-
Chef::Config.from_file(config[:config_file]) if config[:config_file]
60+
Chef::Config.from_file(config[:config_file]) if File.exists?(config[:config_file]) && File.readable?(config[:config_file])
6161
Chef::Config.merge!(config)
6262
end
6363

chef/lib/chef/application/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Chef::Application::Client < Chef::Application
2727
option :config_file,
2828
:short => "-c CONFIG",
2929
:long => "--config CONFIG",
30-
:default => 'config.rb',
30+
:default => 'client.rb',
3131
:description => "The configuration file to use"
3232

3333
option :log_level,

chef/lib/chef/application/indexer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Chef::Application::Indexer < Chef::Application
2929
option :config_file,
3030
:short => "-c CONFIG",
3131
:long => "--config CONFIG",
32-
:default => 'config.rb',
32+
:default => 'indexer.rb',
3333
:description => "The configuration file to use"
3434

3535
option :log_level,

chef/lib/chef/application/solo.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Chef::Application::Solo < Chef::Application
2626
option :config_file,
2727
:short => "-c CONFIG",
2828
:long => "--config CONFIG",
29-
:default => 'config.rb',
29+
:default => 'solo.rb',
3030
:description => "The configuration file to use"
3131

3232
option :log_level,
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#
2+
# Author:: AJ Christensen (<aj@junglist.gen.nz>)
3+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
4+
# License:: Apache License, Version 2.0
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
19+
20+
describe Chef::Application::Indexer, "initialize" do
21+
before do
22+
@app = Chef::Application::Indexer.new
23+
end
24+
25+
it "should create an instance of Chef::Application::Indexer" do
26+
@app.should be_kind_of(Chef::Application::Indexer)
27+
end
28+
end
29+
30+
describe Chef::Application::Indexer, "setup_application" do
31+
before do
32+
@chef_searchindex = mock("Chef::SearchIndex", :null_object => true)
33+
Chef::SearchIndex.stub!(:new).and_return(@chef_searchindex)
34+
Chef::Queue.stub!(:connect).and_return(true)
35+
Chef::Queue.stub!(:subscribe).and_return(true)
36+
@app = Chef::Application::Indexer.new
37+
end
38+
39+
it "should instantiate a chef::client object" do
40+
Chef::SearchIndex.should_receive(:new).and_return(@chef_searchindex)
41+
@app.setup_application
42+
end
43+
44+
it "should connect to the queue" do
45+
Chef::Queue.should_receive(:connect).and_return(true)
46+
@app.setup_application
47+
end
48+
49+
it "should subscribe to index" do
50+
Chef::Queue.should_receive(:subscribe).with(:queue, "index").and_return(true)
51+
@app.setup_application
52+
end
53+
54+
it "should subscribe to remove" do
55+
Chef::Queue.should_receive(:subscribe).with(:queue, "remove").and_return(true)
56+
@app.setup_application
57+
end
58+
end

0 commit comments

Comments
 (0)