summaryrefslogtreecommitdiff
path: root/spec/integration/knife
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2014-05-26 12:14:55 -0700
committerJohn Keiser <jkeiser@opscode.com>2014-05-26 12:14:55 -0700
commit70a5a2b23317887fbdd1e3e6ac580f440a666cac (patch)
tree0e5efeb8911f2677426c10fc1491a01562eaffdc /spec/integration/knife
parent83b2686a59e637f7ac9888b7e370a4b5a7fc59e8 (diff)
downloadchef-70a5a2b23317887fbdd1e3e6ac580f440a666cac.tar.gz
Add "knife serve" to serve up chef repo in chef-zero
Diffstat (limited to 'spec/integration/knife')
-rw-r--r--spec/integration/knife/serve_spec.rb57
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/integration/knife/serve_spec.rb b/spec/integration/knife/serve_spec.rb
new file mode 100644
index 0000000000..ef6990e434
--- /dev/null
+++ b/spec/integration/knife/serve_spec.rb
@@ -0,0 +1,57 @@
+#
+# Author:: John Keiser (<jkeiser@opscode.com>)
+# 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/serve'
+require 'chef/server_api'
+
+describe 'knife serve' do
+ extend IntegrationSupport
+ include KnifeSupport
+ include AppServerSupport
+
+ when_the_repository 'also has one of each thing' do
+ file 'nodes/x.json', { 'foo' => 'bar' }
+
+ it 'knife serve serves up /nodes/x' do
+ exception = nil
+ t = Thread.new do
+ begin
+ knife('serve')
+ rescue
+ exception = $!
+ end
+ end
+ begin
+ Chef::Config.log_level = :debug
+ Chef::Config.chef_server_url = 'http://127.0.0.1:8889'
+ Chef::Config.node_name = nil
+ Chef::Config.client_key = nil
+ api = Chef::ServerAPI.new
+ api.get('nodes/x')['name'].should == 'x'
+ rescue
+ if exception
+ raise exception
+ else
+ raise
+ end
+ ensure
+ t.kill
+ end
+ end
+ end
+end