|
| 1 | +require_relative "../lib/floe/awesome_runner" |
| 2 | + |
| 3 | +RSpec.describe Floe::AwesomeRunner, :uses_awesome_spawn => true do |
| 4 | + let(:subject) { described_class.new(runner_options) } |
| 5 | + let(:runner_options) { {} } |
| 6 | + let(:container_id) { SecureRandom.hex } |
| 7 | + |
| 8 | + # let(:workflow) { make_workflow(ctx, {"State" => {"Type" => "Task", "Resource" => resource, "Parameters" => {"var1.$" => "$.foo.bar"}, "End" => true}}) } |
| 9 | + |
| 10 | + describe "#run_async!" do |
| 11 | + it "raises an exception without a resource" do |
| 12 | + expect { subject.run_async!(nil) }.to raise_error(ArgumentError, "Invalid resource") |
| 13 | + end |
| 14 | + |
| 15 | + it "raises an exception for an invalid resource uri" do |
| 16 | + expect { subject.run_async!("arn:abcd:efgh") }.to raise_error(ArgumentError, "Invalid resource") |
| 17 | + end |
| 18 | + |
| 19 | + it "calls command run with the command name" do |
| 20 | + stub_good_run("ls", :params => [], :env => {}, :output => "file\nlisting\n") |
| 21 | + |
| 22 | + subject.run_async!("awesome://ls") |
| 23 | + end |
| 24 | + |
| 25 | + it "passes environment variables to command run" do |
| 26 | + stub_good_run("ls", :params => [], :env => {"FOO" => "BAR"}, :output => "file\nlisting\n") |
| 27 | + |
| 28 | + subject.run_async!("awesome://ls", {"FOO" => "BAR"}) |
| 29 | + end |
| 30 | + end |
| 31 | + |
| 32 | + # describe "#status!" do |
| 33 | + # let(:runner_context) { {"container_ref" => container_id} } |
| 34 | + |
| 35 | + # it "returns the updated container_state" do |
| 36 | + # stub_good_run!("ls", :params => ["inspect", container_id], :output => "[{\"State\": {\"Running\": true}}]") |
| 37 | + |
| 38 | + # subject.status!(runner_context) |
| 39 | + |
| 40 | + # expect(runner_context).to include("container_state" => {"Running" => true}) |
| 41 | + # end |
| 42 | + # end |
| 43 | + |
| 44 | + describe "#running?" do |
| 45 | + # it "retuns true when running" do |
| 46 | + # runner_context = {"container_ref" => container_id, "container_state" => {"Running" => true}} |
| 47 | + # expect(subject.running?(runner_context)).to be_truthy |
| 48 | + # end |
| 49 | + |
| 50 | + # it "retuns false when not running" do |
| 51 | + # runner_context = {"container_ref" => container_id, "container_state" => {"Running" => false, "ExitCode" => 0}} |
| 52 | + # expect(subject.running?(runner_context)).to be_falsey |
| 53 | + # end |
| 54 | + end |
| 55 | + |
| 56 | + describe "#success?" do |
| 57 | + # it "retuns true when successful" do |
| 58 | + # runner_context = {"container_ref" => container_id, "container_state" => {"Running" => false, "ExitCode" => 0}} |
| 59 | + # expect(subject.success?(runner_context)).to be_truthy |
| 60 | + # end |
| 61 | + |
| 62 | + # it "retuns false when not successful" do |
| 63 | + # runner_context = {"container_ref" => container_id, "container_state" => {"Running" => false, "ExitCode" => 1}} |
| 64 | + # expect(subject.success?(runner_context)).to be_falsey |
| 65 | + # end |
| 66 | + end |
| 67 | + |
| 68 | + describe "#output" do |
| 69 | + let(:runner_context) { {"Output" => ["output1", "output2"]} } |
| 70 | + |
| 71 | + it "returns log output" do |
| 72 | + expect(subject.output(runner_context)).to eq(["output1", "output2"]) |
| 73 | + end |
| 74 | + end |
| 75 | + |
| 76 | + # describe "#cleanup" do |
| 77 | + # end |
| 78 | +end |
0 commit comments