Skip to content
Permalink
Browse files

Fix test for new features

  • Loading branch information...
n0ts committed Feb 12, 2017
1 parent 5bba32b commit 995da4b02f5a72b95a9ae1eb0cb39ea2ddbc19b9
Showing with 73 additions and 51 deletions.
  1. +2 −2 spec/kumogata_convert_spec.rb
  2. +35 −24 spec/kumogata_create_spec.rb
  3. +6 −5 spec/kumogata_crypt_spec.rb
  4. +29 −19 spec/kumogata_update_spec.rb
  5. +1 −1 spec/spec_helper.rb
@@ -614,7 +614,7 @@
}
},
"commands": {
"any_name": {
"any:name": {
"command": {
"Fn::Join": [
"",
@@ -845,7 +845,7 @@
}
},
"commands": {
"any_name": {
"any:name": {
"command": {
"Fn::Join": [
"",
@@ -21,7 +21,8 @@
EOS

run_client(:create, :template => template) do |client, cf|
json = eval_template(template, :update_deletion_policy => true).to_json
template = eval_template(template, :update_deletion_policy => true)
json = JSON.pretty_generate(template)
expect(client).to receive(:print_event_log).twice
expect(client).to receive(:create_event_log).once

@@ -81,7 +82,8 @@
EOS

out = run_client(:create, :template => template, :options => {:detach => true}) do |client, cf|
json = eval_template(template, :update_deletion_policy => true).to_json
template = eval_template(template, :update_deletion_policy => true)
json = JSON.pretty_generate(template)
expect(client).not_to receive(:print_event_log)
expect(client).not_to receive(:create_event_log)

@@ -147,7 +149,8 @@
TEMPLATE

run_client(:create, :template => template) do |client, cf|
json = eval_template(template, :update_deletion_policy => true).to_json
template = eval_template(template, :update_deletion_policy => true)
json = JSON.pretty_generate(template)
expect(client).to receive(:print_event_log).twice
expect(client).to receive(:create_event_log).once

@@ -201,9 +204,9 @@
.and_return(["ap-northeast-1\nap-northeast-1b\n", "", process_status2])

expect(client.instance_variable_get(:@post_processing))
.to receive(:print_command).with('command_a')
.to receive(:print_command).with('command:a')
expect(client.instance_variable_get(:@post_processing))
.to receive(:print_command).with('command_b')
.to receive(:print_command).with('command:b')

expect(client.instance_variable_get(:@post_processing))
.to receive(:print_command_result)
@@ -214,8 +217,8 @@

expect(client.instance_variable_get(:@post_processing))
.to receive(:save_command_results)
.with([{'command_a' => {'ExitStatus' => 0, 'StdOut' => "ap-northeast-1b\nap-northeast-1\n", 'StdErr' => ""}},
{'command_b' => {'ExitStatus' => 0, 'StdOut' => "ap-northeast-1\nap-northeast-1b\n", 'StdErr' => ""}}])
.with([{'command:a' => {'ExitStatus' => 0, 'StdOut' => "ap-northeast-1b\nap-northeast-1\n", 'StdErr' => ""}},
{'command:b' => {'ExitStatus' => 0, 'StdOut' => "ap-northeast-1\nap-northeast-1b\n", 'StdErr' => ""}}])
end
end

@@ -253,7 +256,8 @@
TEMPLATE

run_client(:create, :template => template) do |client, cf|
json = eval_template(template, :update_deletion_policy => true).to_json
template = eval_template(template, :update_deletion_policy => true)
json = JSON.pretty_generate(template)
expect(client).to receive(:print_event_log).twice
expect(client).to receive(:create_event_log).once

@@ -295,15 +299,15 @@
.and_return(["file1\nfile2\n", "", 0])

expect(client.instance_variable_get(:@post_processing))
.to receive(:print_command).with('ssh_command')
.to receive(:print_command).with('ssh:command')

expect(client.instance_variable_get(:@post_processing))
.to receive(:print_command_result)
.with("file1\nfile2\n", "", 0)

expect(client.instance_variable_get(:@post_processing))
.to receive(:save_command_results)
.with([{'ssh_command' => {'ExitStatus' => 0, 'StdOut' => "file1\nfile2\n", 'StdErr' => ""}}])
.with([{'ssh:command' => {'ExitStatus' => 0, 'StdOut' => "file1\nfile2\n", 'StdErr' => ""}}])
end
end

@@ -345,7 +349,8 @@
TEMPLATE

run_client(:create, :template => template) do |client, cf|
json = eval_template(template, :update_deletion_policy => true).to_json
template = eval_template(template, :update_deletion_policy => true)
json = JSON.pretty_generate(template)
expect(client).to receive(:print_event_log).twice
expect(client).to receive(:create_event_log).once

@@ -387,15 +392,15 @@
.and_return(["file1\nfile2\n", "", 0])

expect(client.instance_variable_get(:@post_processing))
.to receive(:print_command).with('ssh_command')
.to receive(:print_command).with('ssh:command')

expect(client.instance_variable_get(:@post_processing))
.to receive(:print_command_result)
.with("file1\nfile2\n", "", 0)

expect(client.instance_variable_get(:@post_processing))
.to receive(:save_command_results)
.with([{'ssh_command' => {'ExitStatus' => 0, 'StdOut' => "file1\nfile2\n", 'StdErr' => ""}}])
.with([{'ssh:command' => {'ExitStatus' => 0, 'StdOut' => "file1\nfile2\n", 'StdErr' => ""}}])
end
end

@@ -444,7 +449,8 @@
TEMPLATE

run_client(:create, :template => template) do |client, cf|
json = eval_template(template, :update_deletion_policy => true).to_json
template = eval_template(template, :update_deletion_policy => true)
json = JSON.pretty_generate(template)
expect(client).to receive(:print_event_log).twice
expect(client).to receive(:create_event_log).once

@@ -498,9 +504,9 @@
.and_return(["ap-northeast-1\nap-northeast-1b\n", "", process_status2])

expect(client.instance_variable_get(:@post_processing))
.to receive(:print_command).with('command_a')
.to receive(:print_command).with('command:a')
expect(client.instance_variable_get(:@post_processing))
.to receive(:print_command).with('command_b')
.to receive(:print_command).with('command:b')

expect(client.instance_variable_get(:@post_processing))
.to receive(:print_command_result)
@@ -511,8 +517,8 @@

expect(client.instance_variable_get(:@post_processing))
.to receive(:save_command_results)
.with([{'command_a' => {'ExitStatus' => 0, 'StdOut' => "ap-northeast-1b\nap-northeast-1\n", 'StdErr' => ""}},
{'command_b' => {'ExitStatus' => 0, 'StdOut' => "ap-northeast-1\nap-northeast-1b\n", 'StdErr' => ""}}])
.with([{'command:a' => {'ExitStatus' => 0, 'StdOut' => "ap-northeast-1b\nap-northeast-1\n", 'StdErr' => ""}},
{'command:b' => {'ExitStatus' => 0, 'StdOut' => "ap-northeast-1\nap-northeast-1b\n", 'StdErr' => ""}}])
end
end

@@ -561,7 +567,8 @@
TEMPLATE

run_client(:create, :template => template) do |client, cf|
json = eval_template(template, :update_deletion_policy => true).to_json
template = eval_template(template, :update_deletion_policy => true)
json = JSON.pretty_generate(template)
expect(client).to receive(:print_event_log).twice
expect(client).to receive(:create_event_log).once

@@ -637,7 +644,7 @@
run_client(:create, :template => template) do |client, cf|
template = eval_template(template, :update_deletion_policy => true)
expect(template['Resources']['myEC2Instance']['DeletionPolicy']).to eq('Delete')
json = template.to_json
json = JSON.pretty_generate(template)
expect(client).to receive(:print_event_log).twice
expect(client).to receive(:create_event_log).once

@@ -705,7 +712,8 @@
EOS

run_client(:create, :template => template, :options => {:parameters => {'InstanceType'=>'m1.large'}}) do |client, cf|
json = eval_template(template, :update_deletion_policy => true).to_json
template = eval_template(template, :update_deletion_policy => true)
json = JSON.pretty_generate(template)
expect(client).to receive(:print_event_log).twice
expect(client).to receive(:create_event_log).once

@@ -765,7 +773,8 @@
EOS

run_client(:create, :arguments => ['MyStack'], :template => template) do |client, cf|
json = eval_template(template).to_json
template = eval_template(template)
json = JSON.pretty_generate(template)
expect(client).to receive(:print_event_log).once

output = make_double('output') do |obj|
@@ -821,7 +830,8 @@
EOS

run_client(:create, :arguments => ['MyStack'], :template => template, :options => {:deletion_policy_retain => true}) do |client, cf|
json = eval_template(template, :update_deletion_policy => true).to_json
template = eval_template(template, :update_deletion_policy => true)
json = JSON.pretty_generate(template)
expect(client).to receive(:print_event_log).once

output = make_double('output') do |obj|
@@ -911,7 +921,8 @@
EOS

run_client(:create, :template => template, :options => {:parameters => {'InstanceType'=>'m1.large'}, :encrypt_parameters => ['Password']}) do |client, cf|
json = eval_template(template, :update_deletion_policy => true, :add_encryption_password => true).to_json
template = eval_template(template, :update_deletion_policy => true, :add_encryption_password => true)
json = JSON.pretty_generate(template)
expect(client).to receive(:print_event_log).twice
expect(client).to receive(:create_event_log).once

@@ -1,14 +1,15 @@
describe Kumogata::Crypt do
it 'encrypt string' do
encrypted = Kumogata::Crypt.encrypt("my_password", "jugem jugem")
decrypted = Kumogata::Crypt.decrypt("my_password", encrypted)
encrypted = Kumogata::Crypt.encrypt("my_password", "jugem jugem")
decrypted = Kumogata::Crypt.decrypt("my_password", encrypted)
expect(decrypted).to eq("jugem jugem")
end

it 'encrypt long string' do
encrypted = Kumogata::Crypt.encrypt("my_password", "jugem jugem" * 10240)
decrypted = Kumogata::Crypt.decrypt("my_password", encrypted)
expect(decrypted).to eq("jugem jugem" * 10240)
len = (RUBY_PLATFORM =~ /darwin/) ? 1 : 10
encrypted = Kumogata::Crypt.encrypt("my_password", "jugem jugem" * 1024 * len)
decrypted = Kumogata::Crypt.decrypt("my_password", encrypted)
expect(decrypted).to eq("jugem jugem" * 1024 * len)
end

it 'make password' do
Oops, something went wrong.

0 comments on commit 995da4b

Please sign in to comment.
You can’t perform that action at this time.