diff --git a/test/import_task_test.rb b/test/import_task_test.rb index 337a432..eb6aad1 100644 --- a/test/import_task_test.rb +++ b/test/import_task_test.rb @@ -2,6 +2,10 @@ require "trailblazer/workflow/task/import" # FIXME. class ImportTaskTest < Minitest::Spec + after do + `rm /tmp/79d163.json` + end + let(:api_key) { "tpka_909ae987_c834_43e4_9869_2eefd2aa9bcf" } let(:trailblazer_pro_host) { "https://testbackend-pro.trb.to" } # NOTE: it's a bit clumsy to share PRO testing knowledge across several gems, but this code belongs here. @@ -18,7 +22,6 @@ class ImportTaskTest < Minitest::Spec #@ Uninitialized sigin initial_session = Trailblazer::Pro::Session::Uninitialized.new(trailblazer_pro_host: trailblazer_pro_host, api_key: api_key) - # 79d163 /tmp/79d163.json signal, (ctx, _) = Trailblazer::Developer.wtf?(Trailblazer::Workflow::Task::Import, [{ session: initial_session, diagram_slug: "79d163", @@ -27,6 +30,24 @@ class ImportTaskTest < Minitest::Spec assert_equal signal.to_h[:semantic], :success assert_equal File.read("/tmp/79d163.json").size, 4635 + end + + it "Import shows HTTP error" do + #@ Uninitialized sigin + initial_session = Trailblazer::Pro::Session::Uninitialized.new(trailblazer_pro_host: trailblazer_pro_host, api_key: "api_key-XXX") + + signal = nil # output, _ = capture_io do + signal, (ctx, _) = Trailblazer::Developer.wtf?(Trailblazer::Workflow::Task::Import, [{ + session: initial_session, + diagram_slug: "79d163", + target_filename: "/tmp/79d163.json", + }, {}]) + # end + + assert_equal signal.to_h[:semantic], :failure + assert_equal File.exist?("/tmp/79d163.json"), false + # assert_equal output.split("\n").last, %(asdf) + assert_equal ctx[:error_message], %(Custom token couldn't be retrieved. HTTP status: 401) end end