lazylead 0.3.0 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.0pdd.yml +4 -1
  3. data/.circleci/config.yml +2 -0
  4. data/.docs/accuracy.md +107 -0
  5. data/.docs/accuracy_email.jpg +0 -0
  6. data/.docs/accuracy_jira_comment.jpg +0 -0
  7. data/.docs/propagate_down.md +1 -1
  8. data/.github/dependabot.yml +6 -0
  9. data/.pdd +1 -1
  10. data/.rubocop.yml +6 -0
  11. data/bin/lazylead +9 -3
  12. data/lazylead.gemspec +5 -4
  13. data/lib/lazylead/cc.rb +12 -6
  14. data/lib/lazylead/cli/app.rb +4 -3
  15. data/lib/lazylead/exchange.rb +1 -1
  16. data/lib/lazylead/log.rb +30 -8
  17. data/lib/lazylead/model.rb +44 -18
  18. data/lib/lazylead/opts.rb +68 -0
  19. data/lib/lazylead/postman.rb +1 -1
  20. data/lib/lazylead/schedule.rb +6 -4
  21. data/lib/lazylead/smtp.rb +1 -1
  22. data/lib/lazylead/system/fake.rb +1 -1
  23. data/lib/lazylead/system/jira.rb +17 -15
  24. data/lib/lazylead/system/synced.rb +2 -1
  25. data/lib/lazylead/task/accuracy/accuracy.rb +140 -0
  26. data/lib/lazylead/task/accuracy/affected_build.rb +43 -0
  27. data/lib/lazylead/task/accuracy/requirement.rb +40 -0
  28. data/lib/lazylead/task/alert.rb +8 -6
  29. data/lib/lazylead/task/confluence_ref.rb +4 -3
  30. data/lib/lazylead/task/echo.rb +4 -0
  31. data/lib/lazylead/task/fix_version.rb +10 -6
  32. data/lib/lazylead/task/missing_comment.rb +7 -5
  33. data/lib/lazylead/task/propagate_down.rb +11 -3
  34. data/lib/lazylead/task/savepoint.rb +1 -1
  35. data/lib/lazylead/task/touch.rb +104 -0
  36. data/lib/lazylead/version.rb +1 -1
  37. data/lib/messages/accuracy.erb +118 -0
  38. data/lib/messages/svn_touch.erb +147 -0
  39. data/readme.md +19 -18
  40. data/test/lazylead/cc_test.rb +22 -2
  41. data/test/lazylead/cli/app_test.rb +2 -2
  42. data/test/lazylead/exchange_test.rb +3 -3
  43. data/test/lazylead/model_test.rb +4 -4
  44. data/test/lazylead/opts_test.rb +70 -0
  45. data/test/lazylead/postman_test.rb +1 -1
  46. data/test/lazylead/smtp_test.rb +1 -1
  47. data/test/lazylead/system/jira_test.rb +35 -1
  48. data/test/lazylead/task/accuracy/accuracy_test.rb +73 -0
  49. data/test/lazylead/task/accuracy/affected_build_test.rb +42 -0
  50. data/test/lazylead/task/assignee_alert_test.rb +2 -2
  51. data/test/lazylead/task/duedate_test.rb +37 -27
  52. data/test/lazylead/task/fix_version_test.rb +9 -6
  53. data/test/lazylead/task/missing_comment_test.rb +11 -9
  54. data/test/lazylead/task/propagate_down_test.rb +4 -2
  55. data/test/lazylead/task/touch_test.rb +61 -0
  56. data/test/test.rb +9 -0
  57. data/upgrades/sqlite/999.testdata.sql +2 -1
  58. metadata +40 -8
  59. data/todo.yml +0 -6
data/readme.md CHANGED
@@ -19,7 +19,7 @@
19
19
  [![DevOps By Rultor.com](http://www.rultor.com/b/dgroup/lazylead)](http://www.rultor.com/p/dgroup/lazylead)
20
20
  [![EO badge](http://www.elegantobjects.org/badge.svg)](http://www.elegantobjects.org/#principles)
21
21
 
22
- ⚠️ We're still in a very early alpha version, the API may change frequently until we release version 1.0.
22
+ ⚠️ We're still in a very early alpha version, the API may change frequently until we release version `1.0`.
23
23
 
24
24
  ### Overview
25
25
  Ticketing systems (Github, Jira, etc.) are strongly integrated into our processes and everyone understands their necessity. As soon as a developer becomes a lead/technical manager, he or she faces a set of routine tasks that are related to ticketing work. On large projects this becomes a problem, more and more you spend time running around on dashboards and tickets, looking for incorrect deviations in tickets and performing routine tasks instead of solving technical problems.
@@ -38,6 +38,7 @@ Join our telegram group [lazylead.org](https://t.me/lazyleads) for discussions.
38
38
  | [Notify about illegal "Fix Version" modification](lib/lazylead/task/fix_version.rb) | ✅ | ❌ | ❌ |
39
39
  | [Expected comment in ticket is missing](lib/lazylead/task/missing_comment.rb) | ✅ | ⌛ | ⌛ |
40
40
  | [Propagate some fields from parent ticket into sub-tasks](.docs/propagate_down.md) | ✅ | ❌ | ❌ |
41
+ | [Evaluate the ticket formatting accuracy](.docs/accuracy.md) | ✅ | ⌛ | ⌛ |
41
42
  | Print the current capacity of team into newly created tasks | ⌛ | ⌛ | ⌛ |
42
43
  | Create/retrofit the defect automatically into latest release | ⌛ | ⌛ | ❌ |
43
44
  | [Notify about expired(ing) due dates](.docs/duedate_expired.md) | ✅ | ❌ | ⌛ |
@@ -61,7 +62,7 @@ Join our telegram group [lazylead.org](https://t.me/lazyleads) for discussions.
61
62
  New ideas, bugs, suggestions or questions are welcome [via GitHub issues](https://github.com/dgroup/lazylead/issues/new)!
62
63
 
63
64
  ### Get started
64
- ⚠️ We're still in a very early alpha version, the API may change frequently until we release version 1.0.
65
+ ⚠️ We're still in a very early alpha version, the API may change frequently until we release version `1.0`.
65
66
 
66
67
  Let's assume that:
67
68
  - your team is using jira as a ticketing system
@@ -112,13 +113,14 @@ For simplicity, we are using [docker-compose](https://docs.docker.com/compose/):
112
113
  ll > docker-compose -f .github/tasks.yml up
113
114
  Creating lazylead ... done
114
115
  Attaching to lazylead
115
- lazylead | [2020-06-06T10:35:13] DEBUG Memory footprint at start is 52MB
116
- lazylead | [2020-06-06T10:35:13] DEBUG Database: '/lazylead/db/ll.db', sql migration dir: '/lazylead/upgrades/sqlite'
117
- lazylead | [2020-06-06T10:35:13] DEBUG Migration applied to /lazylead/db/ll.db from /lazylead/upgrades/sqlite
118
- lazylead | [2020-06-06T10:35:13] DEBUG Database connection established
119
- lazylead | [2020-06-06T10:35:13] WARN SMTP connection enabled in test mode.
120
- lazylead | [2020-06-06T10:35:13] WARN ll-001: No tasks found.
121
- lazylead | [2020-06-06T10:35:13] DEBUG Memory footprint at the end is 66MB
116
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Version: 0.4.0
117
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Memory footprint at start is 52MB
118
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Database: '/lazylead/db/ll.db', sql migration dir: '/lazylead/upgrades/sqlite'
119
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Migration applied to /lazylead/db/ll.db from /lazylead/upgrades/sqlite
120
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Database connection established
121
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] SMTP connection established with {host} as {user}.
122
+ lazylead | [2020-08-09T06:17:32] WARN [main] ll-001: No tasks found.
123
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Memory footprint at the end is 67MB
122
124
  lazylead exited with code 0
123
125
  ll >
124
126
  ```
@@ -152,15 +154,14 @@ For simplicity, we are using [docker-compose](https://docs.docker.com/compose/):
152
154
  check the logs and stop container if needed
153
155
  ```bash
154
156
  ll > docker logs lazylead
155
- 2020-06-06T11:37:36] DEBUG Memory footprint at start is 52MB
156
- [2020-06-06T11:37:37] DEBUG Database: '/lazylead/db/ll.db', sql migration dir: '/lazylead/upgrades/sqlite'
157
- [2020-06-06T11:37:37] DEBUG Migration applied to /lazylead/db/ll.db from /lazylead/upgrades/sqlite
158
- [2020-06-06T11:37:37] DEBUG Database connection established
159
- [2020-06-06T11:37:37] WARN SMTP connection enabled in test mode.
160
- [2020-06-06T11:37:37] DEBUG Task scheduled: id='1', name='Expired due dates', cron='0 8 * * 1-5', system='1', action='Lazylead::Task::AssigneeAlert', team_id='1', description='', enabled='true', properties='{"sql":"filter=555", "cc":"my.email@google.com", "subject":"[LL] Expired due dates", "template":"lib/messages/due_date_expired.erb", "postman":"Lazylead::Exchange"}'
157
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Version: 0.4.0
158
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Memory footprint at start is 52MB
159
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Database: '/lazylead/db/ll.db', sql migration dir: '/lazylead/upgrades/sqlite'
160
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Migration applied to /lazylead/db/ll.db from /lazylead/upgrades/sqlite
161
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Database connection established
162
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] SMTP connection established with {host} as {user}.
163
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Task scheduled: id='1', name='Expired due dates', cron='0 8 * * 1-5', system='1', action='Lazylead::Task::AssigneeAlert', team_id='1', description='', enabled='true', properties='{"sql":"filter=555", "cc":"my.email@google.com", "subject":"[LL] Expired due dates", "template":"lib/messages/due_date_expired.erb", "postman":"Lazylead::Exchange"}'
161
164
  ...
162
- ll > docker stop lazylead
163
- lazylead
164
165
  ```
165
166
 
166
167
  ### How to contribute?
@@ -173,4 +174,4 @@ bundle exec rake
173
174
  Everyone interacting in this project’s codebases, issue trackers, chat rooms is expected to follow the [code of conduct](.github/CODE_OF_CONDUCT.md).
174
175
 
175
176
  Contributors:
176
- * [dgroup](https://github.com/dgroup) as Yurii Dubinka (yurii.dubinka@gmail.com)
177
+ * [dgroup](https://github.com/dgroup) as Yurii Dubinka ([yurii.dubinka@gmail.com](mailto:yurii.dubinka@gmail.com))
@@ -29,6 +29,26 @@ require_relative "../../lib/lazylead/cc"
29
29
  require_relative "../../lib/lazylead/system/jira"
30
30
 
31
31
  module Lazylead
32
+ class CcTest < Lazylead::Test
33
+ test "plain cc detected as text" do
34
+ assert Lazylead::CC.new.plain? "a@fake.com,b@fake.com"
35
+ end
36
+ test "plain cc not found in text" do
37
+ refute Lazylead::CC.new.plain? "justatext.com,eeeee.com"
38
+ end
39
+ test "plain cc detected as object" do
40
+ assert Lazylead::CC.new.recognized? Lazylead::PlainCC.new("a@fake.com")
41
+ end
42
+ test "cc is incorrect" do
43
+ refute Lazylead::CC.new.recognized? key: "value"
44
+ end
45
+ test "cc is not found in hash" do
46
+ assert Lazylead::CC.new.undefined? key: "value"
47
+ end
48
+ test "cc type is blank" do
49
+ assert Lazylead::CC.new.undefined? "type" => " "
50
+ end
51
+ end
32
52
  class PlainCcTest < Lazylead::Test
33
53
  test "cc has valid email" do
34
54
  assert_equal "a@fake.com", Lazylead::PlainCC.new("a@fake.com").cc.first
@@ -109,7 +129,7 @@ module Lazylead
109
129
  end
110
130
 
111
131
  test "detect plain cc" do
112
- CLI::App.new(Log::NOTHING, NoSchedule.new).run(
132
+ CLI::App.new(Log.new, NoSchedule.new).run(
113
133
  home: ".",
114
134
  sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
115
135
  vcs4sql: "upgrades/sqlite",
@@ -120,7 +140,7 @@ module Lazylead
120
140
  end
121
141
 
122
142
  test "detect complex cc by predefined component" do
123
- CLI::App.new(Log::NOTHING, NoSchedule.new).run(
143
+ CLI::App.new(Log.new, NoSchedule.new).run(
124
144
  home: ".",
125
145
  sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
126
146
  vcs4sql: "upgrades/sqlite",
@@ -31,7 +31,7 @@ module Lazylead
31
31
  module CLI
32
32
  class AppTest < Lazylead::SqliteTest
33
33
  test "LL database structure installed successfully" do
34
- CLI::App.new(Log::NOTHING, NoSchedule.new).run(
34
+ CLI::App.new(Log.new, NoSchedule.new).run(
35
35
  home: ".",
36
36
  sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
37
37
  vcs4sql: "upgrades/sqlite"
@@ -46,7 +46,7 @@ module Lazylead
46
46
  end
47
47
 
48
48
  test "activesupport is activated for access to domain entities" do
49
- CLI::App.new(Log::NOTHING, Schedule.new(Log::NOTHING, false)).run(
49
+ CLI::App.new(Log.new, Schedule.new(cling: false)).run(
50
50
  home: ".",
51
51
  sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
52
52
  vcs4sql: "upgrades/sqlite",
@@ -36,7 +36,7 @@ module Lazylead
36
36
  "exchange_user",
37
37
  "exchange_password",
38
38
  "exchange_to"
39
- Exchange.new(Log::NOTHING, NoSalt.new).send(
39
+ Exchange.new(Log.new, NoSalt.new).send(
40
40
  to: ENV["exchange_to"],
41
41
  tickets: NoAuthJira.new("https://jira.spring.io")
42
42
  .issues("key = DATAJDBC-480"),
@@ -52,7 +52,7 @@ module Lazylead
52
52
  "enc_exchange_psw",
53
53
  "enc_exchange_to"
54
54
  Exchange.new(
55
- Log::NOTHING,
55
+ Log.new,
56
56
  Salt.new("exchange_salt"),
57
57
  "exchange_url" => ENV["exchange_url"],
58
58
  "exchange_user" => ENV["enc_exchange_usr"],
@@ -72,7 +72,7 @@ module Lazylead
72
72
  "exchange_password",
73
73
  "exchange_to"
74
74
  Exchange.new(
75
- Log::NOTHING,
75
+ Log.new,
76
76
  Salt.new("exchange_salt"),
77
77
  "exchange_url" => ENV["exchange_url"],
78
78
  "exchange_user" => ENV["enc_exchange_usr"],
@@ -31,7 +31,7 @@ require_relative "../../lib/lazylead/schedule"
31
31
  module Lazylead
32
32
  class OrmTest < Lazylead::SqliteTest
33
33
  test "convert column to json" do
34
- CLI::App.new(Log::NOTHING, NoSchedule.new).run(
34
+ CLI::App.new(Log.new, NoSchedule.new).run(
35
35
  home: ".",
36
36
  sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
37
37
  vcs4sql: "upgrades/sqlite",
@@ -42,7 +42,7 @@ module Lazylead
42
42
 
43
43
  test "env properties injected" do
44
44
  ENV["usr"] = "Mike"
45
- CLI::App.new(Log::NOTHING, NoSchedule.new).run(
45
+ CLI::App.new(Log.new, NoSchedule.new).run(
46
46
  home: ".",
47
47
  sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
48
48
  vcs4sql: "upgrades/sqlite",
@@ -53,7 +53,7 @@ module Lazylead
53
53
  end
54
54
 
55
55
  test "postman initiated through orm" do
56
- CLI::App.new(Log::NOTHING, NoSchedule.new).run(
56
+ CLI::App.new(Log.new, NoSchedule.new).run(
57
57
  home: ".",
58
58
  sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
59
59
  vcs4sql: "upgrades/sqlite",
@@ -64,7 +64,7 @@ module Lazylead
64
64
 
65
65
  test "task properties are using ENV variables" do
66
66
  ENV["key171"] = "value"
67
- CLI::App.new(Log::NOTHING, NoSchedule.new).run(
67
+ CLI::App.new(Log.new, NoSchedule.new).run(
68
68
  home: ".",
69
69
  sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
70
70
  vcs4sql: "upgrades/sqlite",
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The MIT License
4
+ #
5
+ # Copyright (c) 2019-2020 Yurii Dubinka
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"),
9
+ # to deal in the Software without restriction, including without limitation
10
+ # the rights to use, copy, modify, merge, publish, distribute, sublicense,
11
+ # and/or sell copies of the Software, and to permit persons to whom
12
+ # the Software is furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included
15
+ # in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22
+ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
23
+ # OR OTHER DEALINGS IN THE SOFTWARE.
24
+
25
+ require_relative "../test"
26
+ require_relative "../../lib/lazylead/opts"
27
+
28
+ module Lazylead
29
+ class OptsTest < Lazylead::Test
30
+ test "able to read by symbol" do
31
+ assert_equal "1", Opts.new(one: "1", two: "2")[:one]
32
+ end
33
+
34
+ test "able to read by key" do
35
+ assert_equal "1", Opts.new("one" => "1", two: "2")["one"]
36
+ end
37
+
38
+ test "able to write by key" do
39
+ opts = Opts.new
40
+ opts["key"] = "value"
41
+ assert_equal "value", opts["key"]
42
+ end
43
+
44
+ test "has jira defaults" do
45
+ assert_entries(
46
+ {
47
+ max_results: 50
48
+ },
49
+ Opts.new.jira_defaults
50
+ )
51
+ end
52
+
53
+ test "split and trim" do
54
+ assert_equal %w[one two three],
55
+ Opts.new("text" => " one,two ,three, ,\n").slice("text", ",")
56
+ end
57
+
58
+ test "blank for null value cases" do
59
+ assert Opts.new("one" => "1", "two" => nil).blank? "two"
60
+ end
61
+
62
+ test "to hash" do
63
+ assert_kind_of Hash, Opts.new("one" => "1", "two" => nil).to_h
64
+ end
65
+
66
+ test "except keys" do
67
+ assert_equal 1, Opts.new("one" => "1", "two" => "2").except("one").size
68
+ end
69
+ end
70
+ end
@@ -38,7 +38,7 @@ module Lazylead
38
38
  "LL_SMTP_TO",
39
39
  "LL_SMTP_FROM"
40
40
  Smtp.new(
41
- Log::NOTHING,
41
+ Log.new,
42
42
  NoSalt.new,
43
43
  smtp_host: ENV["LL_SMTP_HOST"],
44
44
  smtp_port: ENV["LL_SMTP_PORT"],
@@ -48,7 +48,7 @@ module Lazylead
48
48
  test "email has been sent to the remote server" do
49
49
  skip "Not implemented yet" unless env? "LL_SMTP_HOST", "LL_SMTP_USER"
50
50
  Smtp.new(
51
- Log::NOTHING, NoSalt.new,
51
+ Log.new, NoSalt.new,
52
52
  smtp_host: ENV["LL_SMTP_HOST"],
53
53
  smtp_port: ENV["LL_SMTP_PORT"],
54
54
  smtp_user: ENV["LL_SMTP_USER"],
@@ -40,7 +40,7 @@ module Lazylead
40
40
 
41
41
  test "found issue by jira (ORM)" do
42
42
  skip "No Jira credentials provided" unless env? "jsi_usr", "jsi_psw"
43
- CLI::App.new(Log::NOTHING, NoSchedule.new).run(
43
+ CLI::App.new(Log.new, NoSchedule.new).run(
44
44
  home: ".",
45
45
  sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
46
46
  vcs4sql: "upgrades/sqlite",
@@ -114,5 +114,39 @@ module Lazylead
114
114
  .first
115
115
  .status
116
116
  end
117
+
118
+ test "issue has 1 field" do
119
+ assert_equal 1,
120
+ NoAuthJira.new("https://jira.spring.io")
121
+ .issues("key='DATAJDBC-480'", fields: ["summary"])
122
+ .first
123
+ .fields
124
+ .size
125
+ end
126
+
127
+ test "make an jira comment" do
128
+ issue = Struct.new(:comment) do
129
+ def comments
130
+ self
131
+ end
132
+
133
+ def build
134
+ self
135
+ end
136
+
137
+ def save!(body)
138
+ self[:comment] = body
139
+ end
140
+ end.new
141
+ Issue.new(issue, Fake.new).post("Hi there!")
142
+ assert_equal "Hi there!", issue.comment[:body]
143
+ end
144
+
145
+ test "search by limit in 1 issue" do
146
+ assert_equal 1,
147
+ NoAuthJira.new("https://jira.spring.io")
148
+ .issues("key in (DATAJDBC-480, DATAJDBC-500)", max_results: "1")
149
+ .size
150
+ end
117
151
  end
118
152
  end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The MIT License
4
+ #
5
+ # Copyright (c) 2019-2020 Yurii Dubinka
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"),
9
+ # to deal in the Software without restriction, including without limitation
10
+ # the rights to use, copy, modify, merge, publish, distribute, sublicense,
11
+ # and/or sell copies of the Software, and to permit persons to whom
12
+ # the Software is furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included
15
+ # in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22
+ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
23
+ # OR OTHER DEALINGS IN THE SOFTWARE.
24
+
25
+ require_relative "../../../test"
26
+ require_relative "../../../../lib/lazylead/smtp"
27
+ require_relative "../../../../lib/lazylead/task/accuracy/accuracy"
28
+ require_relative "../../../../lib/lazylead/opts"
29
+ require_relative "../../../../lib/lazylead/postman"
30
+ require_relative "../../../../lib/lazylead/cli/app"
31
+ require_relative "../../../../lib/lazylead/system/jira"
32
+
33
+ module Lazylead
34
+ class AccuracyTest < Lazylead::Test
35
+ test "detect affected build" do
36
+ Lazylead::Smtp.new.enable
37
+ Task::Accuracy.new.run(
38
+ NoAuthJira.new("https://jira.spring.io"),
39
+ Postman.new,
40
+ Opts.new(
41
+ "from" => "ll@fake.com",
42
+ "to" => "lead@fake.com",
43
+ "rules" => "Lazylead::RequirementAffectedBuild",
44
+ "silent" => "true",
45
+ "colors" => {
46
+ "0" => "#FF4F33",
47
+ "35" => "#FF9F33",
48
+ "57" => "#19DD1E",
49
+ "90" => "#0FA81A"
50
+ }.to_json.to_s,
51
+ "docs" => "https://github.com/dgroup/lazylead/blob/master/.github/ISSUE_TEMPLATE/bug_report.md",
52
+ "jql" => "key in (DATAJDBC-490, DATAJDBC-492, DATAJDBC-493)",
53
+ "max_results" => 200,
54
+ "subject" => "[LL] Raised tickets",
55
+ "template" => "lib/messages/accuracy.erb"
56
+ )
57
+ )
58
+ assert_email "[LL] Raised tickets",
59
+ %w[DATAJDBC-493 0.5 100% MyeongHyeonLee Deadlock\ occurs]
60
+ end
61
+
62
+ test "construct accuracy from orm" do
63
+ CLI::App.new(Log.new, NoSchedule.new).run(
64
+ home: ".",
65
+ sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
66
+ vcs4sql: "upgrades/sqlite",
67
+ testdata: true
68
+ )
69
+ assert_kind_of Lazylead::Task::Accuracy,
70
+ ORM::Task.find(195).action.constantize.new
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The MIT License
4
+ #
5
+ # Copyright (c) 2019-2020 Yurii Dubinka
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"),
9
+ # to deal in the Software without restriction, including without limitation
10
+ # the rights to use, copy, modify, merge, publish, distribute, sublicense,
11
+ # and/or sell copies of the Software, and to permit persons to whom
12
+ # the Software is furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included
15
+ # in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22
+ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
23
+ # OR OTHER DEALINGS IN THE SOFTWARE.
24
+
25
+ require_relative "../../../test"
26
+ require_relative "../../../../lib/lazylead/task/accuracy/affected_build"
27
+
28
+ module Lazylead
29
+ class AffectedBuildTest < Lazylead::Test
30
+ test "affected version absent" do
31
+ refute RequirementAffectedBuild.new.passed(
32
+ OpenStruct.new(fields: { "versions" => [] })
33
+ )
34
+ end
35
+
36
+ test "affected version provided" do
37
+ assert RequirementAffectedBuild.new.passed(
38
+ OpenStruct.new(fields: { "versions" => ["0.4.0"] })
39
+ )
40
+ end
41
+ end
42
+ end