spec/shelly/cli/main_spec.rb in shelly-0.4.29 vs spec/shelly/cli/main_spec.rb in shelly-0.4.30
- old
+ new
@@ -973,26 +973,11 @@
@statistics = [{"name" => "app1",
"memory" => {"kilobyte" => "276756", "percent" => "74.1"},
"swap" => {"kilobyte" => "44332", "percent" => "2.8"},
"cpu" => {"wait" => "0.8", "system" => "0.0", "user" => "0.1"},
"load" => {"avg15" => "0.13", "avg05" => "0.15", "avg01" => "0.04"}}]
- @usage = {
- "filesystem" => {
- "avg" => "32 KiB",
- "current" => "64 KiB"
- },
- "database" => {
- "avg" => "64 KiB",
- "current" => "128 KiB"
- },
- "traffic" => {
- "incoming" => "32 KiB",
- "outgoing" => "64 KiB"
- }
- }
@app.stub(:statistics).and_return(@statistics)
- @app.stub(:usage).and_return(@usage)
end
it "should ensure user has logged in" do
hooks(@main, :info).should include(:logged_in?)
end
@@ -1011,24 +996,25 @@
$stdout.should_receive(:puts).with(" Deployed commit sha: 52e65ed2d085eaae560cdb81b2b56a7d76")
$stdout.should_receive(:puts).with(" Deployed commit message: Commit message")
$stdout.should_receive(:puts).with(" Deployed by: megan@example.com")
$stdout.should_receive(:puts).with(" Repository URL: git@winniecloud.net:example-cloud")
$stdout.should_receive(:puts).with(" Web server IP: 22.22.22.22")
- $stdout.should_receive(:puts).with(" Usage:")
- $stdout.should_receive(:puts).with(" Filesystem:")
- $stdout.should_receive(:puts).with(" Average: 32 KiB")
- $stdout.should_receive(:puts).with(" Current: 64 KiB")
- $stdout.should_receive(:puts).with(" Database:")
- $stdout.should_receive(:puts).with(" Average: 64 KiB")
- $stdout.should_receive(:puts).with(" Current: 128 KiB")
- $stdout.should_receive(:puts).with(" Traffic:")
- $stdout.should_receive(:puts).with(" Incoming: 32 KiB")
- $stdout.should_receive(:puts).with(" Outgoing: 64 KiB")
$stdout.should_receive(:puts).with(" Statistics:")
$stdout.should_receive(:puts).with(" app1:")
$stdout.should_receive(:puts).with(" Load average: 1m: 0.04, 5m: 0.15, 15m: 0.13")
$stdout.should_receive(:puts).with(" CPU: 0.8%, MEM: 74.1%, SWAP: 2.8%")
+ $stdout.should_receive(:puts).with(" Usage:")
+ $stdout.should_receive(:puts).with(" Filesystem:")
+ $stdout.should_receive(:puts).with(" Current: 2.04 GiB")
+ $stdout.should_receive(:puts).with(" Average: 182.39 MiB")
+ $stdout.should_receive(:puts).with(" Database:")
+ $stdout.should_receive(:puts).with(" Current: 1.19 MiB")
+ $stdout.should_receive(:puts).with(" Average: 18.24 MiB")
+ $stdout.should_receive(:puts).with(" Traffic:")
+ $stdout.should_receive(:puts).with(" Incoming: 11.54 GiB")
+ $stdout.should_receive(:puts).with(" Outgoing: 1.15 GiB")
+ $stdout.should_receive(:puts).with(" Total: 12.69 GiB")
invoke(@main, :info)
end
context "when deploy failed" do
context "and app is in maintenance" do
@@ -1043,24 +1029,25 @@
$stdout.should_receive(:puts).with(" Deployed commit sha: 52e65ed2d085eaae560cdb81b2b56a7d76")
$stdout.should_receive(:puts).with(" Deployed commit message: Commit message")
$stdout.should_receive(:puts).with(" Deployed by: megan@example.com")
$stdout.should_receive(:puts).with(" Repository URL: git@winniecloud.net:example-cloud")
$stdout.should_receive(:puts).with(" Web server IP: 22.22.22.22")
- $stdout.should_receive(:puts).with(" Usage:")
- $stdout.should_receive(:puts).with(" Filesystem:")
- $stdout.should_receive(:puts).with(" Average: 32 KiB")
- $stdout.should_receive(:puts).with(" Current: 64 KiB")
- $stdout.should_receive(:puts).with(" Database:")
- $stdout.should_receive(:puts).with(" Average: 64 KiB")
- $stdout.should_receive(:puts).with(" Current: 128 KiB")
- $stdout.should_receive(:puts).with(" Traffic:")
- $stdout.should_receive(:puts).with(" Incoming: 32 KiB")
- $stdout.should_receive(:puts).with(" Outgoing: 64 KiB")
$stdout.should_receive(:puts).with(" Statistics:")
$stdout.should_receive(:puts).with(" app1:")
$stdout.should_receive(:puts).with(" Load average: 1m: 0.04, 5m: 0.15, 15m: 0.13")
$stdout.should_receive(:puts).with(" CPU: 0.8%, MEM: 74.1%, SWAP: 2.8%")
+ $stdout.should_receive(:puts).with(" Usage:")
+ $stdout.should_receive(:puts).with(" Filesystem:")
+ $stdout.should_receive(:puts).with(" Current: 2.04 GiB")
+ $stdout.should_receive(:puts).with(" Average: 182.39 MiB")
+ $stdout.should_receive(:puts).with(" Database:")
+ $stdout.should_receive(:puts).with(" Current: 1.19 MiB")
+ $stdout.should_receive(:puts).with(" Average: 18.24 MiB")
+ $stdout.should_receive(:puts).with(" Traffic:")
+ $stdout.should_receive(:puts).with(" Incoming: 11.54 GiB")
+ $stdout.should_receive(:puts).with(" Outgoing: 1.15 GiB")
+ $stdout.should_receive(:puts).with(" Total: 12.69 GiB")
invoke(@main, :info)
end
end
context "and app is not in maintenance" do
@@ -1075,24 +1062,25 @@
$stdout.should_receive(:puts).with(" Deployed commit sha: 52e65ed2d085eaae560cdb81b2b56a7d76")
$stdout.should_receive(:puts).with(" Deployed commit message: Commit message")
$stdout.should_receive(:puts).with(" Deployed by: megan@example.com")
$stdout.should_receive(:puts).with(" Repository URL: git@winniecloud.net:example-cloud")
$stdout.should_receive(:puts).with(" Web server IP: 22.22.22.22")
- $stdout.should_receive(:puts).with(" Usage:")
- $stdout.should_receive(:puts).with(" Filesystem:")
- $stdout.should_receive(:puts).with(" Average: 32 KiB")
- $stdout.should_receive(:puts).with(" Current: 64 KiB")
- $stdout.should_receive(:puts).with(" Database:")
- $stdout.should_receive(:puts).with(" Average: 64 KiB")
- $stdout.should_receive(:puts).with(" Current: 128 KiB")
- $stdout.should_receive(:puts).with(" Traffic:")
- $stdout.should_receive(:puts).with(" Incoming: 32 KiB")
- $stdout.should_receive(:puts).with(" Outgoing: 64 KiB")
$stdout.should_receive(:puts).with(" Statistics:")
$stdout.should_receive(:puts).with(" app1:")
$stdout.should_receive(:puts).with(" Load average: 1m: 0.04, 5m: 0.15, 15m: 0.13")
$stdout.should_receive(:puts).with(" CPU: 0.8%, MEM: 74.1%, SWAP: 2.8%")
+ $stdout.should_receive(:puts).with(" Usage:")
+ $stdout.should_receive(:puts).with(" Filesystem:")
+ $stdout.should_receive(:puts).with(" Current: 2.04 GiB")
+ $stdout.should_receive(:puts).with(" Average: 182.39 MiB")
+ $stdout.should_receive(:puts).with(" Database:")
+ $stdout.should_receive(:puts).with(" Current: 1.19 MiB")
+ $stdout.should_receive(:puts).with(" Average: 18.24 MiB")
+ $stdout.should_receive(:puts).with(" Traffic:")
+ $stdout.should_receive(:puts).with(" Incoming: 11.54 GiB")
+ $stdout.should_receive(:puts).with(" Outgoing: 1.15 GiB")
+ $stdout.should_receive(:puts).with(" Total: 12.69 GiB")
invoke(@main, :info)
end
end
it "should not display statistics when statistics are empty" do
@@ -1117,15 +1105,34 @@
def response(options = {})
{ "code_name" => "foo-production",
"state" => "running",
"state_description" => "running",
- "git_info" =>
- {
+ "git_info" => {
"deployed_commit_message" => "Commit message",
"deployed_commit_sha" => "52e65ed2d085eaae560cdb81b2b56a7d76",
"repository_url" => "git@winniecloud.net:example-cloud",
"deployed_push_author" => "megan@example.com"
+ },
+ "billing" => {
+ "current_month_costs" => {
+ "usage" => [
+ {
+ "kind" => "filesystem",
+ "avg" => 191248000,
+ "current" => 2191248000
+ }, {
+ "kind" => "database",
+ "avg" => 19128000,
+ "current" => 1248000
+ }
+ ],
+ "traffic" => {
+ "incoming" => 12391283291,
+ "outgoing" => 1239123843,
+ "total" => 12391283291 + 1239123843
+ }
+ }
},
"web_server_ip" => "22.22.22.22"}.merge(options)
end
end