Class: Retab::WorkflowTests

Inherits:
Object
  • Object
show all
Defined in:
lib/retab/workflow_tests.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ WorkflowTests

Returns a new instance of WorkflowTests.



9
10
11
# File 'lib/retab/workflow_tests.rb', line 9

def initialize(client)
  @client = client
end

Instance Method Details

#create(workflow_id:, target:, source:, assertion:, name: nil, request_options: {}) ⇒ Retab::WorkflowTest

Create Test

Parameters:

Returns:



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/retab/workflow_tests.rb', line 87

def create(
  workflow_id:,
  target:,
  source:,
  assertion:,
  name: nil,
  request_options: {}
)
  body = {
    "workflow_id" => workflow_id,
    "target" => target,
    "source" => source,
    "name" => name,
    "assertion" => assertion
  }.compact
  response = @client.request(
    method: :post,
    path: "/v1/workflows/tests",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Retab::WorkflowTest.new(response.body)
  result.last_response = Retab::Types::ApiResponse.new(
    http_status: response.code.to_i,
    http_headers: response.each_header.to_h,
    request_id: response["x-request-id"]
  )
  result
end

#delete(test_id:, request_options: {}) ⇒ void

This method returns an undefined value.

Delete Test

Parameters:

  • test_id (String)
  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)



180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/retab/workflow_tests.rb', line 180

def delete(
  test_id:,
  request_options: {}
)
  @client.request(
    method: :delete,
    path: "/v1/workflows/tests/#{Retab::Util.encode_path(test_id)}",
    auth: true,
    request_options: request_options
  )
  nil
end

#get(test_id:, request_options: {}) ⇒ Retab::WorkflowTest

Get Test

Parameters:

  • test_id (String)
  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/retab/workflow_tests.rb', line 122

def get(
  test_id:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/v1/workflows/tests/#{Retab::Util.encode_path(test_id)}",
    auth: true,
    request_options: request_options
  )
  result = Retab::WorkflowTest.new(response.body)
  result.last_response = Retab::Types::ApiResponse.new(
    http_status: response.code.to_i,
    http_headers: response.each_header.to_h,
    request_id: response["x-request-id"]
  )
  result
end

#list(workflow_id:, target_block_id: nil, before: nil, after: nil, limit: 50, order: "desc", request_options: {}) ⇒ Retab::PaginatedList<Retab::WorkflowTest>

List Tests

Parameters:

  • workflow_id (String)
  • target_block_id (String, nil) (defaults to: nil)
  • before (String, nil) (defaults to: nil)
  • after (String, nil) (defaults to: nil)
  • limit (Integer, nil) (defaults to: 50)
  • order (Retab::Types::WorkflowTestsOrder, nil) (defaults to: "desc")
  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/retab/workflow_tests.rb', line 30

def list(
  workflow_id:,
  target_block_id: nil,
  before: nil,
  after: nil,
  limit: 50,
  order: "desc",
  request_options: {}
)
  params = {
    "workflow_id" => workflow_id,
    "target_block_id" => target_block_id,
    "before" => before,
    "after" => after,
    "limit" => limit,
    "order" => order
  }.compact
  response = @client.request(
    method: :get,
    path: "/v1/workflows/tests",
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = -> (cursor) {
    list(
      workflow_id: workflow_id,
      target_block_id: target_block_id,
      before: before,
      after: cursor,
      limit: limit,
      order: order,
      request_options: request_options
    )
  }
  Retab::PaginatedList.from_response(
    response,
    model: Retab::WorkflowTest,
    filters: {
      workflow_id: workflow_id,
      target_block_id: target_block_id,
      before: before,
      limit: limit,
      order: order
    },
    fetch_next: fetch_next
  )
end

#resultsObject



13
14
15
# File 'lib/retab/workflow_tests.rb', line 13

def results
  @results ||= Retab::WorkflowTestRunResults.new(@client)
end

#runsObject



17
18
19
# File 'lib/retab/workflow_tests.rb', line 17

def runs
  @runs ||= Retab::WorkflowTestRuns.new(@client)
end

#update(test_id:, name: nil, assertion: nil, source: nil, request_options: {}) ⇒ Retab::WorkflowTest

Update Test

Parameters:

Returns:



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/retab/workflow_tests.rb', line 148

def update(
  test_id:,
  name: nil,
  assertion: nil,
  source: nil,
  request_options: {}
)
  body = {
    "name" => name,
    "assertion" => assertion,
    "source" => source
  }.compact
  response = @client.request(
    method: :patch,
    path: "/v1/workflows/tests/#{Retab::Util.encode_path(test_id)}",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Retab::WorkflowTest.new(response.body)
  result.last_response = Retab::Types::ApiResponse.new(
    http_status: response.code.to_i,
    http_headers: response.each_header.to_h,
    request_id: response["x-request-id"]
  )
  result
end