Skip to content

Commit

Permalink
test error_message for Import.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Jun 4, 2024
1 parent 1aeaa16 commit cadd128
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion test/import_task_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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",
Expand All @@ -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

0 comments on commit cadd128

Please sign in to comment.