Skip to content

Commit

Permalink
remove Operation.trace and associated concepts such as
Browse files Browse the repository at this point in the history
`Result#wtf`.
  • Loading branch information
apotonick committed Nov 15, 2024
1 parent 84daf29 commit 3f821c7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 114 deletions.
4 changes: 2 additions & 2 deletions lib/trailblazer/operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class << self
require "trailblazer/operation/public_call" # TODO: Remove in 3.0.
extend PublicCall # ::call(params: .., current_user: ..)

require "trailblazer/operation/trace"
extend Trace # ::trace
require "trailblazer/operation/wtf"
extend Wtf # ::trace
end
end

Expand Down
67 changes: 0 additions & 67 deletions lib/trailblazer/operation/trace.rb

This file was deleted.

11 changes: 11 additions & 0 deletions lib/trailblazer/operation/wtf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "trailblazer/developer"

module Trailblazer
class Operation
module Wtf
def wtf?(options)
call_with_public_interface(options, {}, invoke_class: Developer::Wtf)
end
end
end
end
4 changes: 1 addition & 3 deletions test/call_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ def self.add_1(wrap_ctx, original_args)
result.inspect(:seq).must_equal %{<Result:true [[1, :a]] >}

# with tracing
result = operation.trace(seq: [])
result = operation.wtf?(seq: [])

result.inspect(:seq).must_equal %{<Result:true [[1, :a]] >}

result.wtf?
end


Expand Down
44 changes: 2 additions & 42 deletions test/trace_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,13 @@ class Create < Trailblazer::Operation
step ->(_options, params:, **) { params.any? }, id: "Create.task.params"
end

it "deprecates {result.wtf?} and {Operation.trace}" do
output, warning = capture_io do
result = Create.trace({a_return: true, params: {}})
result.wtf?
end
line_no = __LINE__ - 2

assert_equal warning, %([Trailblazer] #{File.realpath(__FILE__)}:#{line_no - 1} Using `Operation.trace` is deprecated and will be removed in {trailblazer-operation-0.11.0}.
Please use `TraceTest::Create.wtf?` as documented here: https://trailblazer.to/2.1/docs/trailblazer#trailblazer-developer-wtf-
[Trailblazer] #{File.realpath(__FILE__)}:#{line_no} Using `result.wtf?` is deprecated. Please use `TraceTest::Create.wtf?` and have a nice day.
)
assert_equal output, %(TraceTest::Create
|-- Start.default
|-- Create.task.a
|-- MyNested
| |-- Start.default
| |-- B.task.b
| |-- B.task.e
| `-- End.success
|-- Create.task.c
|-- Create.task.params
`-- End.failure
)
end

it "allows using low-level Operation::Trace" do
result = Trailblazer::Operation::Trace.(
stack, result = Trailblazer::Developer::Trace.(
Create,
{ a_return: true, params: {} },
)

output = result.wtf
output = Trailblazer::Developer::Trace::Present.(stack)

assert_equal output.gsub(/0x\w+/, "").gsub(/@.+_test/, ""), %{TraceTest::Create
|-- Start.default
Expand All @@ -59,21 +34,6 @@ class Create < Trailblazer::Operation
`-- End.failure}
end

it "Operation::trace" do
result = Create.trace(params: {x: 1}, a_return: true)
assert_equal result.wtf.gsub(/0x\w+/, "").gsub(/@.+_test/, ""), %{TraceTest::Create
|-- Start.default
|-- Create.task.a
|-- MyNested
| |-- Start.default
| |-- B.task.b
| |-- B.task.e
| `-- End.success
|-- Create.task.c
|-- Create.task.params
`-- End.success}
end

it "Operation.wtf?" do
result = nil
output, = capture_io do
Expand Down

0 comments on commit 3f821c7

Please sign in to comment.