Skip to content

Commit

Permalink
test: update specs
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelgomesxyz committed May 2, 2024
1 parent 7ccd0f7 commit 1ac86b3
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions spec/command/run_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@
end

context "when using non-interactive mode" do
let!(:app) { dummy_test_app("full", create_if_not_exists: true) }

context "when workload to clone exists" do
let!(:app) { dummy_test_app("full", create_if_not_exists: true) }

it "clones workload and runs provided command with success", :slow do
result = nil

Expand All @@ -109,7 +109,39 @@
end
end

context "when not specifying image" do
let!(:app) { dummy_test_app }
let!(:cmd) { "'echo $CPLN_IMAGE'" }

before do
run_cpl_command!("apply-template", "gvc", "rails", "-a", app)
run_cpl_command!("build-image", "-a", app)
run_cpl_command!("deploy-image", "-a", app)
run_cpl_command!("build-image", "-a", app)
end

after do
run_cpl_command!("delete", "-a", app, "--yes")
end

it "clones workload and runs with exact same image as original workload after running with latest image", :slow do
result1 = nil
result2 = nil

spawn_cpl_command("run", "-a", app, "--entrypoint", "none", "--image", "latest", "--", cmd) do |it|
result1 = it.read_full_output
end
spawn_cpl_command("run", "-a", app, "--entrypoint", "none", "--", cmd) do |it|
result2 = it.read_full_output
end

expect(result1).to match(%r{/org/.+?/image/#{app}:2})
expect(result2).to match(%r{/org/.+?/image/#{app}:1})
end
end

context "when specifying image" do
let!(:app) { dummy_test_app("full", create_if_not_exists: true) }
let!(:cmd) { "'echo $CPLN_IMAGE'" }

it "clones workload and runs with latest image", :slow do
Expand All @@ -135,6 +167,7 @@

context "when specifying token" do
let!(:token) { Shell.cmd("cpln", "profile", "token", "default")[:output].strip }
let!(:app) { dummy_test_app("full", create_if_not_exists: true) }
let!(:cmd) { "'if [ \"$CPLN_TOKEN\" = \"#{token}\" ]; then echo \"LOCAL\"; else echo \"REMOTE\"; fi'" }

it "clones workload and runs with remote token", :slow do
Expand All @@ -159,6 +192,8 @@
end

context "when detatching" do
let!(:app) { dummy_test_app("full", create_if_not_exists: true) }

it "prints commands to log and stop the job", :slow do
result = nil

Expand Down

0 comments on commit 1ac86b3

Please sign in to comment.