spec/kontena/cli/app/deploy_command_spec.rb in kontena-cli-0.9.3 vs spec/kontena/cli/app/deploy_command_spec.rb in kontena-cli-0.10.0
- old
+ new
@@ -145,15 +145,16 @@
:name =>"kontena-test-wordpress",
:image=>"wordpress:latest",
:env=>["MYSQL_ADMIN_PASSWORD=password", "TEST_ENV_VAR=test", "TEST_ENV_VAR2=test3"],
:container_count=>2,
:stateful=>false,
+ :strategy=>'ha',
:links=>[{:name=>"kontena-test-mysql", :alias=>"db"}],
:ports=>[{:container_port=>"80", :node_port=>"80", :protocol=>"tcp"}]
}
- expect(subject).to receive(:create_service).with('1234567', '1', data)
+ expect(subject).to receive(:create_service).with('1234567', '1', hash_including(data))
subject.run([])
end
end
context 'when yml file has one env file' do
@@ -169,15 +170,16 @@
:name =>"kontena-test-wordpress",
:image=>"wordpress:latest",
:env=>["MYSQL_ADMIN_PASSWORD=password", "TEST_ENV_VAR=test"],
:container_count=>2,
:stateful=>false,
+ :strategy=>'ha',
:links=>[{:name=>"kontena-test-mysql", :alias=>"db"}],
:ports=>[{:container_port=>"80", :node_port=>"80", :protocol=>"tcp"}]
}
- expect(subject).to receive(:create_service).with('1234567', '1', data)
+ expect(subject).to receive(:create_service).with('1234567', '1', hash_including(data))
subject.run([])
end
end
it 'merges external links to links' do
@@ -188,22 +190,29 @@
:name =>"kontena-test-wordpress",
:image=>"wordpress:latest",
:env=> nil,
:container_count=>2,
:stateful=>false,
+ :strategy=>'ha',
:links=>[{:name => "kontena-test-mysql", :alias => "db"}, {:name => "loadbalancer", :alias => "loadbalancer"}],
:ports=>[{:container_port => "80", :node_port => "80", :protocol => "tcp"}]
}
- expect(subject).to receive(:create_service).with('1234567', '1', data)
+ expect(subject).to receive(:create_service).with('1234567', '1', hash_including(data))
subject.run([])
end
it 'creates mysql service before wordpress' do
allow(subject).to receive(:current_dir).and_return("kontena-test")
- data = {:name =>"kontena-test-mysql", :image=>'mysql:5.6', :env=>["MYSQL_ROOT_PASSWORD=kontena-test_secret"], :container_count=>nil, :stateful=>true}
- expect(subject).to receive(:create_service).with('1234567', '1', data)
+ data = {
+ :name =>"kontena-test-mysql",
+ :image=>'mysql:5.6',
+ :env=>["MYSQL_ROOT_PASSWORD=kontena-test_secret"],
+ :container_count=>nil,
+ :stateful=>true,
+ }
+ expect(subject).to receive(:create_service).with('1234567', '1', hash_including(data))
subject.run([])
end
it 'creates wordpress service' do
@@ -213,22 +222,23 @@
:name =>"kontena-test-wordpress",
:image=>"wordpress:4.1",
:env=>["WORDPRESS_DB_PASSWORD=kontena-test_secret"],
:container_count=>2,
:stateful=>true,
+ :strategy=>'ha',
:links=>[{:name=>"kontena-test-mysql", :alias=>"mysql"}],
:ports=>[{:container_port=>"80", :node_port=>"80", :protocol=>"tcp"}]
}
- expect(subject).to receive(:create_service).with('1234567', '1', data)
+ expect(subject).to receive(:create_service).with('1234567', '1', hash_including(data))
subject.run([])
end
it 'deploys services' do
allow(subject).to receive(:current_dir).and_return("kontena-test")
expect(subject).to receive(:deploy_service).with('1234567', 'kontena-test-mysql', {})
- expect(subject).to receive(:deploy_service).with('1234567', 'kontena-test-wordpress', {:strategy => 'ha'})
+ expect(subject).to receive(:deploy_service).with('1234567', 'kontena-test-wordpress', {})
subject.run([])
end
context 'when giving service option' do
it 'deploys only given services' do
@@ -238,8 +248,15 @@
expect(subject).not_to receive(:create).with('mysql', services['mysql'])
subject.run(['wordpress'])
end
end
+ end
+ end
+
+ describe '#parse_data' do
+ it 'adds empty hooks hash if not defined' do
+ data = {'image' => 'foo/bar:latest'}
+ subject.send(:parse_data, data)
end
end
end