Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Fix test for new features
Browse files Browse the repository at this point in the history
  • Loading branch information
n0ts committed Feb 12, 2017
1 parent 5bba32b commit 995da4b
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 51 deletions.
4 changes: 2 additions & 2 deletions spec/kumogata_convert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@
}
},
"commands": {
"any_name": {
"any:name": {
"command": {
"Fn::Join": [
"",
Expand Down Expand Up @@ -845,7 +845,7 @@
}
},
"commands": {
"any_name": {
"any:name": {
"command": {
"Fn::Join": [
"",
Expand Down
59 changes: 35 additions & 24 deletions spec/kumogata_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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|
Expand Down Expand Up @@ -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|
Expand Down Expand Up @@ -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

Expand Down
11 changes: 6 additions & 5 deletions spec/kumogata_crypt_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading

0 comments on commit 995da4b

Please sign in to comment.