require 'spec_helper'

describe "memcached service is not enabled/started" do
  describe service('memcached') do
    it { should_not be_enabled }
    it { should_not be_running }
  end

  describe port(11211) do
    it { should_not be_listening }
  end
end

describe "main memcached class applies successfully" do
  describe command('systemd-run --service-type oneshot --unit puppet-apply --collect -- puppet apply --debug -e "include memcached"') do
    its(:exit_status) { should eq 0 }
  end
end

describe "memcached service is started and listening on port 11211" do
  describe service('memcached') do
    it { should be_running }
  end

  describe port(11211) do
    it { should be_listening }
  end
end

describe "memcached::instance resource applies successfully" do
  describe command('systemd-run --service-type oneshot --unit puppet-apply --collect -- puppet apply --debug -e "memcached::instance{\"11222\":}"') do
    its(:exit_status) { should eq 0 }
  end
end

describe "memcached instance is listening on port 11222" do
  describe service('memcached@11222') do
    it { should be_running }
  end

  describe port(11211) do
    it { should be_listening }
  end
end
