worker_ruby 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/README.md +118 -0
  4. data/VERSION +1 -0
  5. data/VERSION.txt +1 -0
  6. data/docs/Complete.md +10 -0
  7. data/docs/CoreApi.md +200 -0
  8. data/docs/Error.md +8 -0
  9. data/docs/ErrorBody.md +9 -0
  10. data/docs/Group.md +12 -0
  11. data/docs/GroupWrapper.md +8 -0
  12. data/docs/GroupsApi.md +197 -0
  13. data/docs/GroupsWrapper.md +8 -0
  14. data/docs/IdStatus.md +9 -0
  15. data/docs/Image.md +10 -0
  16. data/docs/ImageWrapper.md +8 -0
  17. data/docs/ImagesApi.md +98 -0
  18. data/docs/ImagesWrapper.md +8 -0
  19. data/docs/Job.md +25 -0
  20. data/docs/JobWrapper.md +8 -0
  21. data/docs/JobsApi.md +684 -0
  22. data/docs/JobsWrapper.md +10 -0
  23. data/docs/Log.md +8 -0
  24. data/docs/NewJob.md +14 -0
  25. data/docs/NewJobWithImage.md +15 -0
  26. data/docs/NewJobsWrapper.md +8 -0
  27. data/docs/NewTask.md +14 -0
  28. data/docs/NewTasksWrapper.md +8 -0
  29. data/docs/Reason.md +7 -0
  30. data/docs/RunnerApi.md +170 -0
  31. data/docs/Start.md +8 -0
  32. data/docs/Task.md +25 -0
  33. data/docs/TaskWrapper.md +8 -0
  34. data/docs/TasksApi.md +684 -0
  35. data/docs/TasksWrapper.md +10 -0
  36. data/git_push.sh +67 -0
  37. data/iron_ruby.gemspec +55 -0
  38. data/iron_titan.gemspec +32 -0
  39. data/lib/iron_ruby.rb +66 -0
  40. data/lib/iron_ruby/api/groups_api.rb +262 -0
  41. data/lib/iron_ruby/api/runner_api.rb +229 -0
  42. data/lib/iron_ruby/api/tasks_api.rb +842 -0
  43. data/lib/iron_ruby/api_client.rb +378 -0
  44. data/lib/iron_ruby/api_error.rb +47 -0
  45. data/lib/iron_ruby/configuration.rb +207 -0
  46. data/lib/iron_ruby/models/complete.rb +220 -0
  47. data/lib/iron_ruby/models/error.rb +199 -0
  48. data/lib/iron_ruby/models/error_body.rb +208 -0
  49. data/lib/iron_ruby/models/group.rb +242 -0
  50. data/lib/iron_ruby/models/group_wrapper.rb +200 -0
  51. data/lib/iron_ruby/models/groups_wrapper.rb +202 -0
  52. data/lib/iron_ruby/models/id_status.rb +243 -0
  53. data/lib/iron_ruby/models/new_task.rb +270 -0
  54. data/lib/iron_ruby/models/new_tasks_wrapper.rb +202 -0
  55. data/lib/iron_ruby/models/start.rb +200 -0
  56. data/lib/iron_ruby/models/task.rb +427 -0
  57. data/lib/iron_ruby/models/task_wrapper.rb +200 -0
  58. data/lib/iron_ruby/models/tasks_wrapper.rb +221 -0
  59. data/lib/iron_ruby/version.rb +26 -0
  60. data/lib/iron_titan.rb +66 -0
  61. data/lib/iron_titan/api/core_api.rb +260 -0
  62. data/lib/iron_titan/api/groups_api.rb +262 -0
  63. data/lib/iron_titan/api/images_api.rb +138 -0
  64. data/lib/iron_titan/api/jobs_api.rb +842 -0
  65. data/lib/iron_titan/api/runner_api.rb +229 -0
  66. data/lib/iron_titan/api_client.rb +372 -0
  67. data/lib/iron_titan/api_error.rb +47 -0
  68. data/lib/iron_titan/configuration.rb +186 -0
  69. data/lib/iron_titan/models/complete.rb +220 -0
  70. data/lib/iron_titan/models/error.rb +199 -0
  71. data/lib/iron_titan/models/error_body.rb +208 -0
  72. data/lib/iron_titan/models/group.rb +242 -0
  73. data/lib/iron_titan/models/group_wrapper.rb +200 -0
  74. data/lib/iron_titan/models/groups_wrapper.rb +202 -0
  75. data/lib/iron_titan/models/id_status.rb +243 -0
  76. data/lib/iron_titan/models/image.rb +184 -0
  77. data/lib/iron_titan/models/image_wrapper.rb +161 -0
  78. data/lib/iron_titan/models/images_wrapper.rb +163 -0
  79. data/lib/iron_titan/models/job.rb +427 -0
  80. data/lib/iron_titan/models/job_array.rb +160 -0
  81. data/lib/iron_titan/models/job_wrapper.rb +200 -0
  82. data/lib/iron_titan/models/jobs_wrapper.rb +221 -0
  83. data/lib/iron_titan/models/log.rb +161 -0
  84. data/lib/iron_titan/models/new_job.rb +270 -0
  85. data/lib/iron_titan/models/new_job_array.rb +160 -0
  86. data/lib/iron_titan/models/new_job_with_image.rb +249 -0
  87. data/lib/iron_titan/models/new_jobs_wrapper.rb +202 -0
  88. data/lib/iron_titan/models/reason.rb +164 -0
  89. data/lib/iron_titan/models/start.rb +200 -0
  90. data/lib/iron_titan/version.rb +26 -0
  91. data/lib/worker_ruby.rb +66 -0
  92. data/lib/worker_ruby/api/groups_api.rb +262 -0
  93. data/lib/worker_ruby/api/runner_api.rb +229 -0
  94. data/lib/worker_ruby/api/tasks_api.rb +842 -0
  95. data/lib/worker_ruby/api_client.rb +378 -0
  96. data/lib/worker_ruby/api_error.rb +47 -0
  97. data/lib/worker_ruby/configuration.rb +207 -0
  98. data/lib/worker_ruby/models/complete.rb +220 -0
  99. data/lib/worker_ruby/models/error.rb +199 -0
  100. data/lib/worker_ruby/models/error_body.rb +208 -0
  101. data/lib/worker_ruby/models/group.rb +242 -0
  102. data/lib/worker_ruby/models/group_wrapper.rb +200 -0
  103. data/lib/worker_ruby/models/groups_wrapper.rb +202 -0
  104. data/lib/worker_ruby/models/id_status.rb +243 -0
  105. data/lib/worker_ruby/models/new_task.rb +270 -0
  106. data/lib/worker_ruby/models/new_tasks_wrapper.rb +202 -0
  107. data/lib/worker_ruby/models/start.rb +200 -0
  108. data/lib/worker_ruby/models/task.rb +427 -0
  109. data/lib/worker_ruby/models/task_wrapper.rb +200 -0
  110. data/lib/worker_ruby/models/tasks_wrapper.rb +221 -0
  111. data/lib/worker_ruby/version.rb +26 -0
  112. data/spec/api/CoreApi_spec.rb +99 -0
  113. data/spec/api/JobsApi_spec.rb +131 -0
  114. data/spec/api/core_api_spec.rb +99 -0
  115. data/spec/api/groups_api_spec.rb +94 -0
  116. data/spec/api/images_api_spec.rb +66 -0
  117. data/spec/api/jobs_api_spec.rb +220 -0
  118. data/spec/api/runner_api_spec.rb +88 -0
  119. data/spec/api/tasks_api_spec.rb +220 -0
  120. data/spec/api_client_spec.rb +237 -0
  121. data/spec/configuration_spec.rb +53 -0
  122. data/spec/models/ErrorBody_spec.rb +56 -0
  123. data/spec/models/JobArray_spec.rb +46 -0
  124. data/spec/models/JobWrapper_spec.rb +46 -0
  125. data/spec/models/NewJobArray_spec.rb +46 -0
  126. data/spec/models/NewJob_spec.rb +96 -0
  127. data/spec/models/complete_spec.rb +65 -0
  128. data/spec/models/error_body_spec.rb +59 -0
  129. data/spec/models/error_spec.rb +53 -0
  130. data/spec/models/group_spec.rb +77 -0
  131. data/spec/models/group_wrapper_spec.rb +53 -0
  132. data/spec/models/groups_wrapper_spec.rb +53 -0
  133. data/spec/models/id_status_spec.rb +63 -0
  134. data/spec/models/image_spec.rb +66 -0
  135. data/spec/models/image_wrapper_spec.rb +46 -0
  136. data/spec/models/images_wrapper_spec.rb +46 -0
  137. data/spec/models/job_array_spec.rb +46 -0
  138. data/spec/models/job_spec.rb +161 -0
  139. data/spec/models/job_wrapper_spec.rb +53 -0
  140. data/spec/models/jobs_wrapper_spec.rb +65 -0
  141. data/spec/models/log_spec.rb +46 -0
  142. data/spec/models/new_job_array_spec.rb +46 -0
  143. data/spec/models/new_job_spec.rb +89 -0
  144. data/spec/models/new_job_with_image_spec.rb +116 -0
  145. data/spec/models/new_jobs_wrapper_spec.rb +53 -0
  146. data/spec/models/new_task_spec.rb +89 -0
  147. data/spec/models/new_tasks_wrapper_spec.rb +53 -0
  148. data/spec/models/reason_spec.rb +36 -0
  149. data/spec/models/start_spec.rb +53 -0
  150. data/spec/models/task_spec.rb +163 -0
  151. data/spec/models/task_wrapper_spec.rb +53 -0
  152. data/spec/models/tasks_wrapper_spec.rb +65 -0
  153. data/spec/spec_helper.rb +122 -0
  154. data/worker_ruby-0.5.5.gem +0 -0
  155. data/worker_ruby.gemspec +55 -0
  156. metadata +420 -0
@@ -0,0 +1,88 @@
1
+ =begin
2
+ #IronWorker CE API
3
+
4
+ #The ultimate, language agnostic, container based task processing framework.
5
+
6
+ OpenAPI spec version: 0.5.7
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'spec_helper'
25
+ require 'json'
26
+
27
+ # Unit tests for IronWorker::RunnerApi
28
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
29
+ # Please update as you see appropriate
30
+ describe 'RunnerApi' do
31
+ before do
32
+ # run before each test
33
+ @instance = IronWorker::RunnerApi.new
34
+ end
35
+
36
+ after do
37
+ # run after each test
38
+ end
39
+
40
+ describe 'test an instance of RunnerApi' do
41
+ it 'should create an instact of RunnerApi' do
42
+ expect(@instance).to be_instance_of(IronWorker::RunnerApi)
43
+ end
44
+ end
45
+
46
+ # unit tests for groups_name_tasks_id_error_post
47
+ # Mark task as failed.
48
+ # Task is marked as failed if it was in a valid state. Task's `finished_at` time is initialized.
49
+ # @param name Name of group for this set of tasks.
50
+ # @param id Task id
51
+ # @param body
52
+ # @param [Hash] opts the optional parameters
53
+ # @return [TaskWrapper]
54
+ describe 'groups_name_tasks_id_error_post test' do
55
+ it "should work" do
56
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
57
+ end
58
+ end
59
+
60
+ # unit tests for groups_name_tasks_id_start_post
61
+ # Mark task as started, ie: status = 'running'
62
+ # Task status is changed to 'running' if it was in a valid state before. Task's `started_at` time is initialized.
63
+ # @param name Name of group for this set of tasks.
64
+ # @param id Task id
65
+ # @param body
66
+ # @param [Hash] opts the optional parameters
67
+ # @return [TaskWrapper]
68
+ describe 'groups_name_tasks_id_start_post test' do
69
+ it "should work" do
70
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
71
+ end
72
+ end
73
+
74
+ # unit tests for groups_name_tasks_id_success_post
75
+ # Mark task as succeeded.
76
+ # Task status is changed to succeeded if it was in a valid state before. Task's `completed_at` time is initialized.
77
+ # @param name Name of group for this set of tasks.
78
+ # @param id Task id
79
+ # @param body
80
+ # @param [Hash] opts the optional parameters
81
+ # @return [TaskWrapper]
82
+ describe 'groups_name_tasks_id_success_post test' do
83
+ it "should work" do
84
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
85
+ end
86
+ end
87
+
88
+ end
@@ -0,0 +1,220 @@
1
+ =begin
2
+ #IronWorker CE API
3
+
4
+ #The ultimate, language agnostic, container based task processing framework.
5
+
6
+ OpenAPI spec version: 0.5.7
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'spec_helper'
25
+ require 'json'
26
+
27
+ # Unit tests for IronWorker::TasksApi
28
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
29
+ # Please update as you see appropriate
30
+ describe 'TasksApi' do
31
+ before do
32
+ # run before each test
33
+ @instance = IronWorker::TasksApi.new
34
+ end
35
+
36
+ after do
37
+ # run after each test
38
+ end
39
+
40
+ describe 'test an instance of TasksApi' do
41
+ it 'should create an instact of TasksApi' do
42
+ expect(@instance).to be_instance_of(IronWorker::TasksApi)
43
+ end
44
+ end
45
+
46
+ # unit tests for groups_name_tasks_get
47
+ # Get task list by group name.
48
+ # This will list tasks for a particular group.
49
+ # @param name Name of group for this set of tasks.
50
+ # @param [Hash] opts the optional parameters
51
+ # @option opts [DateTime] :created_after Will return tasks created after this time. In RFC3339 format.
52
+ # @option opts [Integer] :n Number of tasks to return per page. Default is 50. Max is 1000.
53
+ # @option opts [String] :cursor Pass this in from a previous query to paginate results.
54
+ # @return [TasksWrapper]
55
+ describe 'groups_name_tasks_get test' do
56
+ it "should work" do
57
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
58
+ end
59
+ end
60
+
61
+ # unit tests for groups_name_tasks_id_cancel_post
62
+ # Cancel a task.
63
+ # Cancels a task in delayed, queued or running status. The worker may continue to run a running task. reason is set to `client_request`. The task's completed_at field is set to the current time on the taskserver.
64
+ # @param name Name of group for this set of tasks.
65
+ # @param id Task id
66
+ # @param [Hash] opts the optional parameters
67
+ # @return [TaskWrapper]
68
+ describe 'groups_name_tasks_id_cancel_post test' do
69
+ it "should work" do
70
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
71
+ end
72
+ end
73
+
74
+ # unit tests for groups_name_tasks_id_delete
75
+ # Delete the task.
76
+ # Delete only succeeds if task status is one of `succeeded | failed | cancelled`. Cancel a task if it is another state and needs to be deleted. All information about the task, including the log, is irretrievably lost when this is invoked.
77
+ # @param name Name of group for this set of tasks.
78
+ # @param id Task id
79
+ # @param [Hash] opts the optional parameters
80
+ # @return [nil]
81
+ describe 'groups_name_tasks_id_delete test' do
82
+ it "should work" do
83
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
84
+ end
85
+ end
86
+
87
+ # unit tests for groups_name_tasks_id_error_post
88
+ # Mark task as failed.
89
+ # Task is marked as failed if it was in a valid state. Task's `finished_at` time is initialized.
90
+ # @param name Name of group for this set of tasks.
91
+ # @param id Task id
92
+ # @param body
93
+ # @param [Hash] opts the optional parameters
94
+ # @return [TaskWrapper]
95
+ describe 'groups_name_tasks_id_error_post test' do
96
+ it "should work" do
97
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
98
+ end
99
+ end
100
+
101
+ # unit tests for groups_name_tasks_id_get
102
+ # Gets task by id
103
+ # Gets a task by id.
104
+ # @param name Name of group for this set of tasks.
105
+ # @param id task id
106
+ # @param [Hash] opts the optional parameters
107
+ # @return [TaskWrapper]
108
+ describe 'groups_name_tasks_id_get test' do
109
+ it "should work" do
110
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
111
+ end
112
+ end
113
+
114
+ # unit tests for groups_name_tasks_id_log_get
115
+ # Get the log of a completed task.
116
+ # Retrieves the log from log storage.
117
+ # @param name Name of group for this set of tasks.
118
+ # @param id Task id
119
+ # @param [Hash] opts the optional parameters
120
+ # @return [String]
121
+ describe 'groups_name_tasks_id_log_get test' do
122
+ it "should work" do
123
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
124
+ end
125
+ end
126
+
127
+ # unit tests for groups_name_tasks_id_log_post
128
+ # Send in a log for storage.
129
+ # Logs are sent after a task completes since they may be very large and the runner can process the next task.
130
+ # @param name Name of group for this set of tasks.
131
+ # @param id Task id
132
+ # @param log Output log for the task. Content-Type must be \"text/plain; charset=utf-8\".
133
+ # @param [Hash] opts the optional parameters
134
+ # @return [TaskWrapper]
135
+ describe 'groups_name_tasks_id_log_post test' do
136
+ it "should work" do
137
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
138
+ end
139
+ end
140
+
141
+ # unit tests for groups_name_tasks_id_retry_post
142
+ # Retry a task.
143
+ # \"The /retry endpoint can be used to force a retry of tasks with status succeeded, cancelled or failed. The retried task has the same attributes. max_retries is not modified.\"
144
+ # @param name Name of group for this set of tasks.
145
+ # @param id Task id
146
+ # @param [Hash] opts the optional parameters
147
+ # @return [TaskWrapper]
148
+ describe 'groups_name_tasks_id_retry_post test' do
149
+ it "should work" do
150
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
151
+ end
152
+ end
153
+
154
+ # unit tests for groups_name_tasks_id_start_post
155
+ # Mark task as started, ie: status = 'running'
156
+ # Task status is changed to 'running' if it was in a valid state before. Task's `started_at` time is initialized.
157
+ # @param name Name of group for this set of tasks.
158
+ # @param id Task id
159
+ # @param body
160
+ # @param [Hash] opts the optional parameters
161
+ # @return [TaskWrapper]
162
+ describe 'groups_name_tasks_id_start_post test' do
163
+ it "should work" do
164
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
165
+ end
166
+ end
167
+
168
+ # unit tests for groups_name_tasks_id_success_post
169
+ # Mark task as succeeded.
170
+ # Task status is changed to succeeded if it was in a valid state before. Task's `completed_at` time is initialized.
171
+ # @param name Name of group for this set of tasks.
172
+ # @param id Task id
173
+ # @param body
174
+ # @param [Hash] opts the optional parameters
175
+ # @return [TaskWrapper]
176
+ describe 'groups_name_tasks_id_success_post test' do
177
+ it "should work" do
178
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
179
+ end
180
+ end
181
+
182
+ # unit tests for groups_name_tasks_id_touch_post
183
+ # Extend task timeout.
184
+ # Consumers can sometimes take a while to run the task after accepting it. An example is when the runner does not have the docker image locally, it can spend a significant time downloading the image. If the timeout is small, the task may never get to run, or run but not be accepted by Titan. Consumers can touch the task before it times out. Titan will reset the timeout, giving the consumer another timeout seconds to run the task. Touch is only valid while the task is in a running state. If touch fails, the runner may stop running the task.
185
+ # @param name Name of group for this set of tasks.
186
+ # @param id Task id
187
+ # @param [Hash] opts the optional parameters
188
+ # @return [nil]
189
+ describe 'groups_name_tasks_id_touch_post test' do
190
+ it "should work" do
191
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
192
+ end
193
+ end
194
+
195
+ # unit tests for groups_name_tasks_post
196
+ # Enqueue task
197
+ # Enqueues task(s). If any of the tasks is invalid, none of the tasks are enqueued.
198
+ # @param name name of the group.
199
+ # @param body Array of tasks to post.
200
+ # @param [Hash] opts the optional parameters
201
+ # @return [TasksWrapper]
202
+ describe 'groups_name_tasks_post test' do
203
+ it "should work" do
204
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
205
+ end
206
+ end
207
+
208
+ # unit tests for tasks_get
209
+ # Get next task.
210
+ # Gets the next task in the queue, ready for processing. Titan may return <=n tasks. Consumers should start processing tasks in order. Each returned task is set to `status` \"running\" and `started_at` is set to the current time. No other consumer can retrieve this task.
211
+ # @param [Hash] opts the optional parameters
212
+ # @option opts [Integer] :n Number of tasks to return.
213
+ # @return [TasksWrapper]
214
+ describe 'tasks_get test' do
215
+ it "should work" do
216
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
217
+ end
218
+ end
219
+
220
+ end
@@ -0,0 +1,237 @@
1
+ =begin
2
+ #IronWorker CE API
3
+
4
+ #The ultimate, language agnostic, container based task processing framework.
5
+
6
+ OpenAPI spec version: 0.5.7
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'spec_helper'
25
+
26
+ describe IronWorker::ApiClient do
27
+ context 'initialization' do
28
+ context 'URL stuff' do
29
+ context 'host' do
30
+ it 'removes http from host' do
31
+ IronWorker.configure { |c| c.host = 'http://example.com' }
32
+ expect(IronWorker::Configuration.default.host).to eq('example.com')
33
+ end
34
+
35
+ it 'removes https from host' do
36
+ IronWorker.configure { |c| c.host = 'https://wookiee.com' }
37
+ expect(IronWorker::ApiClient.default.config.host).to eq('wookiee.com')
38
+ end
39
+
40
+ it 'removes trailing path from host' do
41
+ IronWorker.configure { |c| c.host = 'hobo.com/v4' }
42
+ expect(IronWorker::Configuration.default.host).to eq('hobo.com')
43
+ end
44
+ end
45
+
46
+ context 'base_path' do
47
+ it "prepends a slash to base_path" do
48
+ IronWorker.configure { |c| c.base_path = 'v4/dog' }
49
+ expect(IronWorker::Configuration.default.base_path).to eq('/v4/dog')
50
+ end
51
+
52
+ it "doesn't prepend a slash if one is already there" do
53
+ IronWorker.configure { |c| c.base_path = '/v4/dog' }
54
+ expect(IronWorker::Configuration.default.base_path).to eq('/v4/dog')
55
+ end
56
+
57
+ it "ends up as a blank string if nil" do
58
+ IronWorker.configure { |c| c.base_path = nil }
59
+ expect(IronWorker::Configuration.default.base_path).to eq('')
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ describe "params_encoding in #build_request" do
66
+ let(:config) { IronWorker::Configuration.new }
67
+ let(:api_client) { IronWorker::ApiClient.new(config) }
68
+
69
+ it "defaults to nil" do
70
+ expect(IronWorker::Configuration.default.params_encoding).to eq(nil)
71
+ expect(config.params_encoding).to eq(nil)
72
+
73
+ request = api_client.build_request(:get, '/test')
74
+ expect(request.options[:params_encoding]).to eq(nil)
75
+ end
76
+
77
+ it "can be customized" do
78
+ config.params_encoding = :multi
79
+ request = api_client.build_request(:get, '/test')
80
+ expect(request.options[:params_encoding]).to eq(:multi)
81
+ end
82
+ end
83
+
84
+ describe "timeout in #build_request" do
85
+ let(:config) { IronWorker::Configuration.new }
86
+ let(:api_client) { IronWorker::ApiClient.new(config) }
87
+
88
+ it "defaults to 0" do
89
+ expect(IronWorker::Configuration.default.timeout).to eq(0)
90
+ expect(config.timeout).to eq(0)
91
+
92
+ request = api_client.build_request(:get, '/test')
93
+ expect(request.options[:timeout]).to eq(0)
94
+ end
95
+
96
+ it "can be customized" do
97
+ config.timeout = 100
98
+ request = api_client.build_request(:get, '/test')
99
+ expect(request.options[:timeout]).to eq(100)
100
+ end
101
+ end
102
+
103
+ describe "#deserialize" do
104
+ it "handles Array<Integer>" do
105
+ api_client = IronWorker::ApiClient.new
106
+ headers = {'Content-Type' => 'application/json'}
107
+ response = double('response', headers: headers, body: '[12, 34]')
108
+ data = api_client.deserialize(response, 'Array<Integer>')
109
+ expect(data).to be_instance_of(Array)
110
+ expect(data).to eq([12, 34])
111
+ end
112
+
113
+ it "handles Array<Array<Integer>>" do
114
+ api_client = IronWorker::ApiClient.new
115
+ headers = {'Content-Type' => 'application/json'}
116
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
117
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
118
+ expect(data).to be_instance_of(Array)
119
+ expect(data).to eq([[12, 34], [56]])
120
+ end
121
+
122
+ it "handles Hash<String, String>" do
123
+ api_client = IronWorker::ApiClient.new
124
+ headers = {'Content-Type' => 'application/json'}
125
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
126
+ data = api_client.deserialize(response, 'Hash<String, String>')
127
+ expect(data).to be_instance_of(Hash)
128
+ expect(data).to eq({:message => 'Hello'})
129
+ end
130
+ end
131
+
132
+ describe "#object_to_hash" do
133
+ it "ignores nils and includes empty arrays" do
134
+ # uncomment below to test object_to_hash for model
135
+ #api_client = IronWorker::ApiClient.new
136
+ #_model = IronWorker::ModelName.new
137
+ # update the model attribute below
138
+ #_model.id = 1
139
+ # update the expected value (hash) below
140
+ #expected = {id: 1, name: '', tags: []}
141
+ #expect(api_client.object_to_hash(_model)).to eq(expected)
142
+ end
143
+ end
144
+
145
+ describe "#build_collection_param" do
146
+ let(:param) { ['aa', 'bb', 'cc'] }
147
+ let(:api_client) { IronWorker::ApiClient.new }
148
+
149
+ it "works for csv" do
150
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
151
+ end
152
+
153
+ it "works for ssv" do
154
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
155
+ end
156
+
157
+ it "works for tsv" do
158
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
159
+ end
160
+
161
+ it "works for pipes" do
162
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
163
+ end
164
+
165
+ it "works for multi" do
166
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
167
+ end
168
+
169
+ it "fails for invalid collection format" do
170
+ expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
171
+ end
172
+ end
173
+
174
+ describe "#json_mime?" do
175
+ let(:api_client) { IronWorker::ApiClient.new }
176
+
177
+ it "works" do
178
+ expect(api_client.json_mime?(nil)).to eq false
179
+ expect(api_client.json_mime?('')).to eq false
180
+
181
+ expect(api_client.json_mime?('application/json')).to eq true
182
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
183
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
184
+
185
+ expect(api_client.json_mime?('application/xml')).to eq false
186
+ expect(api_client.json_mime?('text/plain')).to eq false
187
+ expect(api_client.json_mime?('application/jsonp')).to eq false
188
+ end
189
+ end
190
+
191
+ describe "#select_header_accept" do
192
+ let(:api_client) { IronWorker::ApiClient.new }
193
+
194
+ it "works" do
195
+ expect(api_client.select_header_accept(nil)).to be_nil
196
+ expect(api_client.select_header_accept([])).to be_nil
197
+
198
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
199
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
200
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
201
+
202
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
203
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
204
+ end
205
+ end
206
+
207
+ describe "#select_header_content_type" do
208
+ let(:api_client) { IronWorker::ApiClient.new }
209
+
210
+ it "works" do
211
+ expect(api_client.select_header_content_type(nil)).to eq('application/json')
212
+ expect(api_client.select_header_content_type([])).to eq('application/json')
213
+
214
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
215
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
216
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
217
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
218
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
219
+ end
220
+ end
221
+
222
+ describe "#sanitize_filename" do
223
+ let(:api_client) { IronWorker::ApiClient.new }
224
+
225
+ it "works" do
226
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
227
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
228
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
229
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
230
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
231
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
232
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
233
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
234
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
235
+ end
236
+ end
237
+ end