lazylead 0.4.3 → 0.5.0

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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/.docs/accuracy.md +2 -2
  3. data/.docs/duedate_expired.md +3 -3
  4. data/.docs/propagate_down.md +3 -3
  5. data/.gitattributes +1 -0
  6. data/Rakefile +2 -0
  7. data/bin/lazylead +1 -1
  8. data/lazylead.gemspec +2 -2
  9. data/lib/lazylead/exchange.rb +15 -8
  10. data/lib/lazylead/model.rb +35 -1
  11. data/lib/lazylead/opts.rb +12 -0
  12. data/lib/lazylead/schedule.rb +16 -15
  13. data/lib/lazylead/system/jira.rb +39 -0
  14. data/lib/lazylead/task/accuracy/accuracy.rb +4 -8
  15. data/lib/lazylead/task/accuracy/affected_build.rb +2 -6
  16. data/lib/lazylead/task/accuracy/attachment.rb +44 -0
  17. data/lib/lazylead/task/accuracy/environment.rb +39 -0
  18. data/lib/lazylead/task/accuracy/logs.rb +40 -0
  19. data/lib/lazylead/task/accuracy/records.rb +45 -0
  20. data/lib/lazylead/task/accuracy/requirement.rb +9 -0
  21. data/lib/lazylead/task/accuracy/servers.rb +50 -0
  22. data/lib/lazylead/task/accuracy/stacktrace.rb +63 -0
  23. data/lib/lazylead/task/accuracy/testcase.rb +75 -0
  24. data/lib/lazylead/task/accuracy/wiki.rb +41 -0
  25. data/lib/lazylead/task/echo.rb +18 -0
  26. data/lib/lazylead/task/fix_version.rb +9 -2
  27. data/lib/lazylead/task/touch.rb +23 -8
  28. data/lib/lazylead/version.rb +1 -1
  29. data/lib/messages/svn_log.erb +117 -0
  30. data/license.txt +1 -1
  31. data/readme.md +5 -5
  32. data/test/lazylead/cli/app_test.rb +11 -11
  33. data/test/lazylead/system/jira_test.rb +30 -0
  34. data/test/lazylead/task/accuracy/accuracy_test.rb +1 -1
  35. data/test/lazylead/task/accuracy/affected_build_test.rb +2 -2
  36. data/test/lazylead/task/accuracy/attachment_test.rb +50 -0
  37. data/test/lazylead/task/accuracy/environment_test.rb +42 -0
  38. data/test/lazylead/task/accuracy/logs_test.rb +78 -0
  39. data/test/lazylead/task/accuracy/records_test.rb +60 -0
  40. data/test/lazylead/task/accuracy/servers_test.rb +66 -0
  41. data/test/lazylead/task/accuracy/stacktrace_test.rb +113 -0
  42. data/test/lazylead/task/accuracy/testcase_test.rb +205 -0
  43. data/test/lazylead/task/accuracy/wiki_test.rb +40 -0
  44. data/test/lazylead/task/touch_test.rb +28 -1
  45. data/test/test.rb +16 -0
  46. data/upgrades/sqlite/001-install-main-lazylead-tables.sql +1 -5
  47. data/upgrades/sqlite/999.testdata.sql +12 -17
  48. metadata +28 -4
  49. data/.travis.yml +0 -16
@@ -66,20 +66,14 @@ module Lazylead
66
66
  start = (now.to_time - opts["period"].to_i).to_datetime
67
67
  cmd = [
68
68
  "svn log --no-auth-cache",
69
- "--username #{decrypt(opts['svn_user'])}",
70
- "--password #{decrypt(opts['svn_password'])}",
69
+ "--username #{opts.decrypt('svn_user', 'svn_salt')}",
70
+ "--password #{opts.decrypt('svn_password', 'svn_salt')}",
71
71
  "--xml -v -r {#{start}}:{#{now}} #{opts['svn_url']}"
72
72
  ]
73
73
  raw = `#{cmd.join(" ")}`
74
74
  Nokogiri.XML(raw, nil, "UTF-8")
75
75
  end
76
76
 
77
- # Decrypt text using cryptography salt
78
- def decrypt(text, sid = "svn_salt")
79
- return Salt.new(sid).decrypt(text) if ENV.key? sid
80
- text
81
- end
82
-
83
77
  # Convert single revision(XML text) to entry object.
84
78
  # Entry object is a simple ruby struct object.
85
79
  def to_entry(xml)
@@ -100,5 +94,26 @@ module Lazylead
100
94
  )
101
95
  end
102
96
  end
97
+
98
+ #
99
+ # Send notification about modification of svn files since particular
100
+ # revision.
101
+ #
102
+ class SvnLog
103
+ def initialize(log = Log.new)
104
+ @log = log
105
+ end
106
+
107
+ def run(_, postman, opts)
108
+ cmd = [
109
+ "svn log --diff --no-auth-cache",
110
+ "--username #{opts.decrypt('svn_user', 'svn_salt')}",
111
+ "--password #{opts.decrypt('svn_password', 'svn_salt')}",
112
+ "-r#{opts['since_rev']}:HEAD #{opts['svn_url']}"
113
+ ]
114
+ stdout = `#{cmd.join(" ")}`
115
+ postman.send(opts.merge(stdout: stdout)) unless stdout.blank?
116
+ end
117
+ end
103
118
  end
104
119
  end
@@ -23,5 +23,5 @@
23
23
  # OR OTHER DEALINGS IN THE SOFTWARE.
24
24
 
25
25
  module Lazylead
26
- VERSION = "0.4.3"
26
+ VERSION = "0.5.0"
27
27
  end
@@ -0,0 +1,117 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <style>
5
+ /* CSS styles taken from https://github.com/yegor256/tacit */
6
+ pre, code, kbd, samp, var, output {
7
+ font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
8
+ font-size: 14.4px
9
+ }
10
+
11
+ pre code {
12
+ background: none;
13
+ border: 0;
14
+ line-height: 29.7px;
15
+ padding: 0
16
+ }
17
+
18
+ code, kbd {
19
+ background: #daf1e0;
20
+ border-radius: 3.6px;
21
+ color: #2a6f3b;
22
+ display: inline-block;
23
+ line-height: 18px;
24
+ padding: 3.6px 6.3px 2.7px
25
+ }
26
+
27
+ a {
28
+ color: #275a90;
29
+ text-decoration: none
30
+ }
31
+
32
+ a:hover {
33
+ text-decoration: underline
34
+ }
35
+
36
+ * {
37
+ border: 0;
38
+ border-collapse: separate;
39
+ border-spacing: 0;
40
+ box-sizing: border-box;
41
+ margin: 0;
42
+ max-width: 100%;
43
+ padding: 0;
44
+ vertical-align: baseline;
45
+ font-family: system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
46
+ font-size: 13px;
47
+ font-stretch: normal;
48
+ font-style: normal;
49
+ font-weight: 400;
50
+ line-height: 29.7px
51
+ }
52
+
53
+ html, body {
54
+ width: 100%
55
+ }
56
+
57
+ html {
58
+ height: 100%
59
+ }
60
+
61
+ body {
62
+ background: #fff;
63
+ color: #1a1919;
64
+ padding: 36px
65
+ }
66
+
67
+ .commit {
68
+ min-width: 100%;
69
+ border-radius: 3.5px;
70
+ overflow: hidden;
71
+ display: inline-block;
72
+ line-height: 15px;
73
+ font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
74
+ border: 1px solid #BCC6CC;
75
+ }
76
+
77
+ .commit * {
78
+ padding-left: 4px;
79
+ font-size: 8px;
80
+ line-height: 15px;
81
+ }
82
+ </style>
83
+ <title>SVN log</title>
84
+ </head>
85
+ <body>
86
+ <p>Hi,</p>
87
+ <p>The following file(s) changed since <code><%= since_rev %></code> rev in <a href="<%= svn_url %>"><%= svn_url %></a>:</p>
88
+ <% stdout.split("------------------------------------------------------------------------").reject(&:blank?).reverse.each do |commit| %>
89
+ <div class="commit">
90
+ <% commit.split("\n").reject(&:blank?).each_with_index do |line, index| %>
91
+ <% if index.zero? %>
92
+ <% details = line.split("|").map(&:strip).reject(&:blank?) %>
93
+ <p style="background: gainsboro;">
94
+ <a href="<%= commit_url %><%= details[0][1 .. -1] %>"><%= details[0] %></a>
95
+ by<a href="<%= user %><%= details[1] %>"><%= details[1] %></a>
96
+ at<span style="color: #275a90;"><%= details[2] %></span>
97
+ </p>
98
+ <% else %>
99
+ <% if line.start_with?("+++") || line.start_with?("---") %>
100
+ <p style="background: gainsboro;"><%= line.gsub(/[<>]/, '<' => '&lt;', '>' => '&gt;') %></p>
101
+ <% elsif line.start_with?("+") %>
102
+ <p style="<%= "background: darkseagreen;" %>"><%= line.gsub(/[<>]/, '<' => '&lt;', '>' => '&gt;') %></p>
103
+ <% elsif line.start_with?("-") %>
104
+ <p style="<%= "background: lightsalmon;" %>"><%= line.gsub(/[<>]/, '<' => '&lt;', '>' => '&gt;') %></p>
105
+ <% else %>
106
+ <p style="background: gainsboro;"><%= line.gsub(/[<>]/,'<' => '&lt;', '>' => '&gt;') %></p>
107
+ <% end %>
108
+ <% end %>
109
+ <% end %>
110
+ </div>
111
+ <br/><br/><br/>
112
+ <% end %>
113
+ <p>Posted by
114
+ <a href="https://github.com/dgroup/lazylead">lazylead v<%= version %></a>.
115
+ </p>
116
+ </body>
117
+ </html>
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2019-2020 Yurii Dubinka
3
+ Copyright (c) 2019-2021 Yurii Dubinka
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"),
data/readme.md CHANGED
@@ -113,7 +113,7 @@ For simplicity, we are using [docker-compose](https://docs.docker.com/compose/):
113
113
  ll > docker-compose -f .github/tasks.yml up
114
114
  Creating lazylead ... done
115
115
  Attaching to lazylead
116
- lazylead | [2020-08-09T06:17:32] DEBUG [main] Version: 0.4.0
116
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Version: 0.5.0
117
117
  lazylead | [2020-08-09T06:17:32] DEBUG [main] Memory footprint at start is 52MB
118
118
  lazylead | [2020-08-09T06:17:32] DEBUG [main] Database: '/lazylead/db/ll.db', sql migration dir: '/lazylead/upgrades/sqlite'
119
119
  lazylead | [2020-08-09T06:17:32] DEBUG [main] Migration applied to /lazylead/db/ll.db from /lazylead/upgrades/sqlite
@@ -135,16 +135,16 @@ For simplicity, we are using [docker-compose](https://docs.docker.com/compose/):
135
135
  values (1, 'Dream team with lazylead', '{}');
136
136
  insert into systems(id, properties)
137
137
  values (1,'{"type":"Lazylead::Jira", "username":"${jira_user}", "password":"${jira_password}", "site":"${jira_url}", "context_path":""}');
138
- insert into tasks (name, cron, enabled, id, system, team_id, action, properties)
138
+ insert into tasks (name, schedule, enabled, id, system, team_id, action, properties)
139
139
  values ('Expired due dates',
140
- '0 8 * * 1-5',
140
+ 'cron:0 8 * * 1-5',
141
141
  'true',
142
142
  1, 1, 1,
143
143
  'Lazylead::Task::AssigneeAlert',
144
144
  '{"sql":"filter=555", "cc":"<youremail.com>", "subject":"[LL] Expired due dates", "template":"lib/messages/due_date_expired.erb", "postman":"Lazylead::Exchange"}');
145
145
 
146
146
  ```
147
- Yes, for task scheduling we are using [cron](https://crontab.guru).
147
+ Yes, for task scheduling we are using [cron](https://crontab.guru) here, but you may use other scheduling types from [rufus-scheduler](https://github.com/jmettraux/rufus-scheduler).
148
148
 
149
149
  4. Once you changed `./ll.db`, please restart the container using `docker-compose -f .github/tasks.yml restart`
150
150
  ```bash
@@ -154,7 +154,7 @@ For simplicity, we are using [docker-compose](https://docs.docker.com/compose/):
154
154
  check the logs and stop container if needed
155
155
  ```bash
156
156
  ll > docker logs lazylead
157
- lazylead | [2020-08-09T06:17:32] DEBUG [main] Version: 0.4.0
157
+ lazylead | [2020-08-09T06:17:32] DEBUG [main] Version: 0.5.0
158
158
  lazylead | [2020-08-09T06:17:32] DEBUG [main] Memory footprint at start is 52MB
159
159
  lazylead | [2020-08-09T06:17:32] DEBUG [main] Database: '/lazylead/db/ll.db', sql migration dir: '/lazylead/upgrades/sqlite'
160
160
  lazylead | [2020-08-09T06:17:32] DEBUG [main] Migration applied to /lazylead/db/ll.db from /lazylead/upgrades/sqlite
@@ -39,14 +39,14 @@ module Lazylead
39
39
  assert_tables "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
40
40
  systems: %w[id properties],
41
41
  teams: %w[id name properties],
42
- tasks: %w[id name cron system action team_id enabled properties]
42
+ tasks: %w[id name schedule system action team_id enabled properties]
43
43
  assert_fk "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
44
44
  %w[tasks team_id teams id],
45
45
  %w[tasks system systems id]
46
46
  end
47
47
 
48
48
  test "activesupport is activated for access to domain entities" do
49
- CLI::App.new(Log.new, Schedule.new(cling: false)).run(
49
+ CLI::App.new(Log.new, NoSchedule.new).run(
50
50
  home: ".",
51
51
  sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
52
52
  vcs4sql: "upgrades/sqlite",
@@ -57,16 +57,16 @@ module Lazylead
57
57
  "Required team record wasn't found in the database"
58
58
  end
59
59
 
60
- # @todo #10/DEV Think about using "timecop" >v0.9.1 gem in order to make
61
- # E2E application skeleton https://stackoverflow.com/questions/59955571.
62
- # The depedency for gemspec should be after *thin* in .gemspec
63
- # ..
64
- # s.add_runtime_dependency "thin", "1.7.2"
65
- # s.add_runtime_dependency "timecop", "0.9.1"
66
- # ..
67
- # More https://github.com/travisjeffery/timecop
68
60
  test "scheduled task was triggered successfully" do
69
- skip "Not implemented yet"
61
+ CLI::App.new(Log.new, Schedule.new(cling: false)).run(
62
+ home: ".",
63
+ sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
64
+ vcs4sql: "upgrades/sqlite",
65
+ testdata: true
66
+ )
67
+ sleep 0.4
68
+ assert (Time.now - 5.seconds) < Time.parse(File.open("test/resources/echo.txt").first),
69
+ "Scheduled task wasn't executed few seconds ago"
70
70
  end
71
71
  end
72
72
  end
@@ -148,5 +148,35 @@ module Lazylead
148
148
  .issues("key in (DATAJDBC-480, DATAJDBC-500)", max_results: "1")
149
149
  .size
150
150
  end
151
+
152
+ test "description is correct" do
153
+ assert_words %w[DATACMNS-1639\ moved\ entity\ instantiators],
154
+ NoAuthJira.new("https://jira.spring.io")
155
+ .issues("key=DATAJDBC-480")
156
+ .first
157
+ .description
158
+ end
159
+
160
+ test "component is correct" do
161
+ assert_equal %w[Stream\ Module],
162
+ NoAuthJira.new("https://jira.spring.io")
163
+ .issues("key=XD-3766")
164
+ .first
165
+ .components
166
+ end
167
+
168
+ test "field found" do
169
+ assert_includes NoAuthJira.new("https://jira.spring.io")
170
+ .issues("key=DATAJDBC-480")
171
+ .first["description"],
172
+ "DATACMNS-1639 moved "
173
+ end
174
+
175
+ test "field not found" do
176
+ assert NoAuthJira.new("https://jira.spring.io")
177
+ .issues("key=DATAJDBC-480")
178
+ .first["absent field"]
179
+ .blank?
180
+ end
151
181
  end
152
182
  end
@@ -40,7 +40,7 @@ module Lazylead
40
40
  Opts.new(
41
41
  "from" => "ll@fake.com",
42
42
  "to" => "lead@fake.com",
43
- "rules" => "Lazylead::RequirementAffectedBuild",
43
+ "rules" => "Lazylead::AffectedBuild",
44
44
  "silent" => "true",
45
45
  "colors" => {
46
46
  "0" => "#FF4F33",
@@ -28,13 +28,13 @@ require_relative "../../../../lib/lazylead/task/accuracy/affected_build"
28
28
  module Lazylead
29
29
  class AffectedBuildTest < Lazylead::Test
30
30
  test "affected version absent" do
31
- refute RequirementAffectedBuild.new.passed(
31
+ refute AffectedBuild.new.passed(
32
32
  OpenStruct.new(fields: { "versions" => [] })
33
33
  )
34
34
  end
35
35
 
36
36
  test "affected version provided" do
37
- assert RequirementAffectedBuild.new.passed(
37
+ assert AffectedBuild.new.passed(
38
38
  OpenStruct.new(fields: { "versions" => ["0.4.0"] })
39
39
  )
40
40
  end
@@ -0,0 +1,50 @@
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/log"
27
+ require_relative "../../../../lib/lazylead/system/jira"
28
+ require_relative "../../../../lib/lazylead/task/accuracy/attachment"
29
+
30
+ module Lazylead
31
+ class AttachmentTest < Lazylead::Test
32
+ class Txt < Attachment
33
+ def initialize
34
+ super "", 0, ""
35
+ end
36
+
37
+ def matching(attach)
38
+ "ConfigServerLogWithException.txt".eql? attach.attrs["filename"]
39
+ end
40
+ end
41
+
42
+ test "attachment is present" do
43
+ assert Txt.new.passed(
44
+ NoAuthJira.new("https://jira.spring.io")
45
+ .issues("key=XD-3761", fields: ["attachment"])
46
+ .first
47
+ )
48
+ end
49
+ end
50
+ 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/environment"
27
+
28
+ module Lazylead
29
+ class EnvironmentTest < Lazylead::Test
30
+ test "environment absent" do
31
+ refute Environment.new.passed(
32
+ OpenStruct.new(fields: { "environment" => "" })
33
+ )
34
+ end
35
+
36
+ test "environment provided" do
37
+ assert Environment.new.passed(
38
+ OpenStruct.new(fields: { "environment" => "http://host:port" })
39
+ )
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,78 @@
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/logs"
27
+
28
+ module Lazylead
29
+ class LogsTest < Lazylead::Test
30
+ test "log file is present" do
31
+ assert Logs.new.passed(
32
+ OpenStruct.new(
33
+ attachments: [
34
+ OpenStruct.new(
35
+ attrs: { "size" => 10_241, "filename" => "catalina.log" }
36
+ )
37
+ ]
38
+ )
39
+ )
40
+ end
41
+
42
+ test "log file is present but name in uppercase" do
43
+ assert Logs.new.passed(
44
+ OpenStruct.new(
45
+ attachments: [
46
+ OpenStruct.new(
47
+ attrs: { "size" => 10_241, "filename" => "catalina.LOG" }
48
+ )
49
+ ]
50
+ )
51
+ )
52
+ end
53
+
54
+ test "attachment isn't a log file" do
55
+ refute Logs.new.passed(
56
+ OpenStruct.new(
57
+ attachments: [
58
+ OpenStruct.new(
59
+ attrs: { "size" => 10_001, "filename" => "readme.md" }
60
+ )
61
+ ]
62
+ )
63
+ )
64
+ end
65
+
66
+ test "log file size less than 10KB" do
67
+ refute Logs.new.passed(
68
+ OpenStruct.new(
69
+ attachments: [
70
+ OpenStruct.new(
71
+ attrs: { "size" => 10_000, "filename" => "catalina.log" }
72
+ )
73
+ ]
74
+ )
75
+ )
76
+ end
77
+ end
78
+ end