require_relative "spec_helper" describe "openstack-dashboard::server" do before { dashboard_stubs } describe "opensuse" do context "mysql backend" do before do @chef_run = ::ChefSpec::ChefRunner.new ::OPENSUSE_OPTS ::Chef::Recipe.any_instance.stub(:db).with("dashboard").and_return( {"db_type" => "mysql", "db_name" => "flying_dolphin"}) @chef_run.converge "openstack-dashboard::server" end it "installs mysql packages when mysql backend is configured" do @chef_run = ::ChefSpec::ChefRunner.new ::OPENSUSE_OPTS ::Chef::Recipe.any_instance.stub(:db).with("dashboard").and_return( {"db_type" => "mysql", "db_name" => "flying_dolphin"}) @chef_run.converge "openstack-dashboard::server" expect(@chef_run).to upgrade_package "python-mysql" end end context "postgresql backend" do before do @chef_run = ::ChefSpec::ChefRunner.new ::OPENSUSE_OPTS ::Chef::Recipe.any_instance.stub(:db).with("dashboard").and_return( {"db_type" => "postgresql", "db_name" => "flying_elephant"}) @chef_run.converge "openstack-dashboard::server" end it "installs packages" do expect(@chef_run).to upgrade_package "openstack-dashboard" end it "installs postgresql packages" do expect(@chef_run).to upgrade_package "python-psycopg2" end it "creates local_settings.py" do file = @chef_run.template "/usr/share/openstack-dashboard/openstack_dashboard/local/local_settings.py" expect(@chef_run).to create_file_with_content(file.name, "autogenerated") end it "creates .blackhole dir with proper owner" do dir = "/usr/share/openstack-dashboard/openstack_dashboard/.blackhole" expect(@chef_run.directory(dir)).to be_owned_by "root" end it "creates an openstack-dashboard virtual host with proper DocRoot" do # XXX this should be hardcoded to /etc/apache2/... , but the # upstream cookbook is broken for SUSE # see for e.g. http://tickets.opscode.com/browse/COOK-2434 file = @chef_run.template "#{@chef_run.node["apache"]["dir"]}/conf.d/openstack-dashboard.conf" expect(@chef_run).to create_file_with_content(file.name, "DocumentRoot /usr/share/openstack-dashboard/openstack_dashboard/.blackhole/") end end end end