judges 0.53.5 → 0.53.7

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +20 -18
  3. data/features/test.feature +2 -2
  4. data/judges.gemspec +2 -2
  5. data/lib/judges/commands/push.rb +3 -3
  6. data/lib/judges/commands/update.rb +8 -1
  7. data/lib/judges.rb +1 -1
  8. metadata +1 -39
  9. data/.0pdd.yml +0 -8
  10. data/.gitattributes +0 -7
  11. data/.github/workflows/actionlint.yml +0 -25
  12. data/.github/workflows/codecov.yml +0 -27
  13. data/.github/workflows/copyrights.yml +0 -19
  14. data/.github/workflows/eslint.yml +0 -20
  15. data/.github/workflows/markdown-lint.yml +0 -23
  16. data/.github/workflows/pdd.yml +0 -19
  17. data/.github/workflows/rake.yml +0 -28
  18. data/.github/workflows/reuse.yml +0 -19
  19. data/.github/workflows/typos.yml +0 -19
  20. data/.github/workflows/xcop.yml +0 -19
  21. data/.github/workflows/yamllint.yml +0 -19
  22. data/.gitignore +0 -12
  23. data/.pdd +0 -7
  24. data/.rubocop.yml +0 -53
  25. data/.rultor.yml +0 -37
  26. data/renovate.json +0 -6
  27. data/test/commands/test_download.rb +0 -127
  28. data/test/commands/test_eval.rb +0 -28
  29. data/test/commands/test_import.rb +0 -40
  30. data/test/commands/test_inspect.rb +0 -44
  31. data/test/commands/test_join.rb +0 -38
  32. data/test/commands/test_print.rb +0 -146
  33. data/test/commands/test_pull.rb +0 -77
  34. data/test/commands/test_push.rb +0 -79
  35. data/test/commands/test_test.rb +0 -217
  36. data/test/commands/test_trim.rb +0 -31
  37. data/test/commands/test_update.rb +0 -282
  38. data/test/commands/test_upload.rb +0 -119
  39. data/test/test__helper.rb +0 -45
  40. data/test/test_bin.rb +0 -26
  41. data/test/test_categories.rb +0 -33
  42. data/test/test_impex.rb +0 -35
  43. data/test/test_judge.rb +0 -114
  44. data/test/test_judges.rb +0 -137
  45. data/test/test_options.rb +0 -88
  46. data/test/test_to_rel.rb +0 -24
@@ -1,127 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'loog'
7
- require 'webmock/minitest'
8
- require_relative '../../lib/judges'
9
- require_relative '../../lib/judges/commands/download'
10
- require_relative '../test__helper'
11
-
12
- # Test.
13
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
14
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
15
- # License:: MIT
16
- class TestDownload < Minitest::Test
17
- def test_download_simple_durable
18
- WebMock.disable_net_connect!
19
- content = 'Hello, World!'
20
- stub_request(:get, 'https://example.org/durables/find?file=downloaded.txt&jname=myjudge').to_return(
21
- status: 200, body: '42'
22
- )
23
- stub_request(:get, 'https://example.org/csrf').to_return(body: 'test-csrf-token')
24
- stub_request(:post, %r{https://example.org/durables/42/lock}).to_return(status: 302)
25
- stub_request(:get, 'https://example.org/durables/42').to_return(
26
- status: 200, body: content, headers: {}
27
- )
28
- stub_request(:post, %r{https://example.org/durables/42/unlock}).to_return(status: 302)
29
- Dir.mktmpdir do |d|
30
- file = File.join(d, 'downloaded.txt')
31
- Judges::Download.new(Loog::NULL).run(
32
- {
33
- 'token' => '000',
34
- 'host' => 'example.org',
35
- 'port' => 443,
36
- 'ssl' => true,
37
- 'owner' => 'default'
38
- },
39
- ['myjudge', file]
40
- )
41
- assert_equal(content, File.read(file))
42
- end
43
- end
44
-
45
- def test_download_with_custom_owner
46
- WebMock.disable_net_connect!
47
- content = 'Custom content'
48
- stub_request(:get, %r{http://example.org/durables/find}).to_return(
49
- status: 200, body: '123'
50
- )
51
- stub_request(:get, 'http://example.org/csrf').to_return(body: 'test-csrf-token')
52
- stub_request(:post, %r{http://example.org/durables/123/lock}).to_return(status: 302)
53
- stub_request(:get, 'http://example.org/durables/123').to_return(
54
- status: 200, body: content, headers: {}
55
- )
56
- stub_request(:post, %r{http://example.org/durables/123/unlock}).to_return(status: 302)
57
- Dir.mktmpdir do |d|
58
- file = File.join(d, 'data.bin')
59
- Judges::Download.new(Loog::NULL).run(
60
- {
61
- 'token' => '000',
62
- 'host' => 'example.org',
63
- 'port' => 80,
64
- 'ssl' => false,
65
- 'owner' => 'custom'
66
- },
67
- ['judge1', file]
68
- )
69
- assert_equal(content, File.read(file))
70
- end
71
- end
72
-
73
- def test_fails_on_http_error
74
- WebMock.disable_net_connect!
75
- stub_request(:get, 'http://example.org/durables/find?file=test.txt&jname=somejudge').to_return(
76
- status: 200, body: '99'
77
- )
78
- stub_request(:get, 'http://example.org/csrf').to_return(body: 'test-csrf-token')
79
- stub_request(:post, %r{http://example.org/durables/99/lock}).to_return(status: 302)
80
- stub_request(:get, 'http://example.org/durables/99').to_return(status: 404)
81
- stub_request(:post, %r{http://example.org/durables/99/unlock}).to_return(status: 302)
82
- Dir.mktmpdir do |d|
83
- file = File.join(d, 'test.txt')
84
- assert_raises(StandardError) do
85
- Judges::Download.new(Loog::NULL).run(
86
- {
87
- 'token' => '000',
88
- 'host' => 'example.org',
89
- 'port' => 80,
90
- 'ssl' => false,
91
- 'owner' => 'none'
92
- },
93
- ['somejudge', file]
94
- )
95
- end
96
- end
97
- end
98
-
99
- def test_fails_with_wrong_number_of_arguments
100
- assert_raises(RuntimeError) do
101
- Judges::Download.new(Loog::NULL).run({}, ['only_one_arg'])
102
- end
103
- assert_raises(RuntimeError) do
104
- Judges::Download.new(Loog::NULL).run({}, %w[too many args])
105
- end
106
- end
107
-
108
- def test_handles_not_found_durable
109
- WebMock.disable_net_connect!
110
- stub_request(:get, 'http://example.org/durables/find?file=missing.txt&jname=notfound').to_return(
111
- status: 404
112
- )
113
- Dir.mktmpdir do |d|
114
- file = File.join(d, 'missing.txt')
115
- Judges::Download.new(Loog::NULL).run(
116
- {
117
- 'token' => '000',
118
- 'host' => 'example.org',
119
- 'port' => 80,
120
- 'ssl' => false
121
- },
122
- ['notfound', file]
123
- )
124
- refute_path_exists(file)
125
- end
126
- end
127
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'loog'
7
- require 'nokogiri'
8
- require 'factbase/to_xml'
9
- require_relative '../test__helper'
10
- require_relative '../../lib/judges'
11
- require_relative '../../lib/judges/commands/eval'
12
-
13
- # Test.
14
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
15
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
16
- # License:: MIT
17
- class TestEval < Minitest::Test
18
- def test_build_factbase_from_scratch
19
- Dir.mktmpdir do |d|
20
- file = File.join(d, 'base.fb')
21
- Judges::Eval.new(Loog::NULL).run({}, [file, '$fb.insert.foo = 42'])
22
- fb = Factbase.new
23
- fb.import(File.binread(file))
24
- xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
25
- refute_empty(xml.xpath('/fb/f[foo="42"]'), xml)
26
- end
27
- end
28
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'loog'
7
- require 'nokogiri'
8
- require 'factbase/to_xml'
9
- require_relative '../test__helper'
10
- require_relative '../../lib/judges'
11
- require_relative '../../lib/judges/commands/import'
12
-
13
- # Test.
14
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
15
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
16
- # License:: MIT
17
- class TestImport < Minitest::Test
18
- def test_import_from_yaml
19
- Dir.mktmpdir do |d|
20
- file = File.join(d, 'base.fb')
21
- yaml = File.join(d, 'input.yml')
22
- save_it(
23
- yaml,
24
- <<-YAML
25
- -
26
- foo: 42
27
- bar: 2024-03-04T22:22:22Z
28
- t: Hello, world!
29
- -
30
- z: 3.14
31
- YAML
32
- )
33
- Judges::Import.new(Loog::NULL).run({}, [yaml, file])
34
- fb = Factbase.new
35
- fb.import(File.binread(file))
36
- xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
37
- refute_empty(xml.xpath('/fb[count(f)=2]'), xml)
38
- end
39
- end
40
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'factbase'
7
- require 'loog'
8
- require_relative '../../lib/judges'
9
- require_relative '../../lib/judges/commands/inspect'
10
- require_relative '../test__helper'
11
-
12
- # Test.
13
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
14
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
15
- # License:: MIT
16
- class TestInspect < Minitest::Test
17
- def test_simple_inspect
18
- Dir.mktmpdir do |d|
19
- f = File.join(d, 'base.fb')
20
- fb = Factbase.new
21
- fb.insert
22
- fb.insert
23
- File.binwrite(f, fb.export)
24
- loog = Loog::Buffer.new
25
- Judges::Inspect.new(loog).run({}, [f])
26
- assert_includes(loog.to_s, 'Facts: 2')
27
- end
28
- end
29
-
30
- def test_simple_inspect_with_summary
31
- Dir.mktmpdir do |d|
32
- f = File.join(d, 'base.fb')
33
- fb = Factbase.new
34
- fb.insert.then do |f|
35
- f.what = 'judges-summary'
36
- f.error = 'something'
37
- end
38
- File.binwrite(f, fb.export)
39
- loog = Loog::Buffer.new
40
- Judges::Inspect.new(loog).run({}, [f])
41
- assert_includes(loog.to_s, 'Facts: 1')
42
- end
43
- end
44
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'factbase/to_xml'
7
- require 'loog'
8
- require 'nokogiri'
9
- require_relative '../../lib/judges'
10
- require_relative '../../lib/judges/commands/join'
11
- require_relative '../test__helper'
12
-
13
- # Test.
14
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
15
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
16
- # License:: MIT
17
- class TestJoin < Minitest::Test
18
- def test_simple_join
19
- Dir.mktmpdir do |d|
20
- master = File.join(d, 'master.fb')
21
- fb1 = Factbase.new
22
- fb1.insert.zz = 5
23
- File.binwrite(master, fb1.export)
24
- slave = File.join(d, 'slave.fb')
25
- fb2 = Factbase.new
26
- fb2.insert.foo_bar = 42
27
- File.binwrite(slave, fb2.export)
28
- loog = Loog::Buffer.new
29
- Judges::Join.new(loog).run({}, [master, slave])
30
- fb = Factbase.new
31
- fb.import(File.binread(master))
32
- xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
33
- refute_empty(xml.xpath('/fb/f[zz="5"]'), xml)
34
- refute_empty(xml.xpath('/fb/f[foo_bar="42"]'), xml)
35
- assert_includes(loog.to_s, 'Two factbases joined', loog.to_s)
36
- end
37
- end
38
- end
@@ -1,146 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'factbase'
7
- require 'fileutils'
8
- require 'loog'
9
- require 'nokogiri'
10
- require 'online'
11
- require 'securerandom'
12
- require 'w3c_validators'
13
- require 'webmock/minitest'
14
- require 'yaml'
15
- require_relative '../../lib/judges'
16
- require_relative '../../lib/judges/commands/print'
17
- require_relative '../test__helper'
18
-
19
- # Test.
20
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
21
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
22
- # License:: MIT
23
- class TestPrint < Minitest::Test
24
- def test_simple_print
25
- Dir.mktmpdir do |d|
26
- f = File.join(d, 'base.fb')
27
- fb = Factbase.new
28
- fb.insert
29
- File.binwrite(f, fb.export)
30
- Judges::Print.new(Loog::NULL).run({ 'format' => 'yaml', 'auto' => true }, [f])
31
- y = File.join(d, 'base.yaml')
32
- assert_path_exists(y)
33
- assert_equal(1, YAML.load_file(y).size)
34
- end
35
- end
36
-
37
- def test_print_to_html
38
- WebMock.disable_net_connect!
39
- stub_request(:get, 'https://yegor256.github.io/judges/assets/index.css').to_return(body: 'nothing')
40
- stub_request(:get, 'https://yegor256.github.io/judges/assets/index.js').to_return(body: 'nothing')
41
- fb = Factbase.new
42
- fb.insert
43
- 10.times do
44
- f = fb.insert
45
- f._id = 44
46
- f.what = SecureRandom.hex(10)
47
- f.when = Time.now
48
- f.details = 'hey, друг'
49
- f.ticket = 42
50
- f.ticket = 55
51
- f.pi = 3.1416
52
- f.long_property = 'test_' * 100
53
- end
54
- html = File.join(__dir__, '../../temp/base.html')
55
- FileUtils.rm_f(html)
56
- Dir.mktmpdir do |d|
57
- f = File.join(d, 'base.fb')
58
- File.binwrite(f, fb.export)
59
- Judges::Print.new(Loog::NULL).run(
60
- { 'format' => 'html', 'columns' => 'what,when,ticket' },
61
- [f, html]
62
- )
63
- end
64
- doc = File.read(html)
65
- xml =
66
- begin
67
- Nokogiri::XML.parse(doc) do |c|
68
- c.norecover
69
- c.strict
70
- end
71
- rescue StandardError => e
72
- raise "#{doc}\n\n#{e}"
73
- end
74
- assert_empty(xml.errors, xml)
75
- refute_empty(xml.xpath('/html'), xml)
76
- WebMock.enable_net_connect!
77
- skip('We are offline') unless online?
78
- begin
79
- v = W3CValidators::NuValidator.new.validate_file(html)
80
- assert_empty(v.errors, "#{doc}\n\n#{v.errors.join('; ')}")
81
- rescue W3CValidators::ValidatorUnavailable
82
- skip('Cloud validator is too busy')
83
- end
84
- end
85
-
86
- def test_html_table_has_colgroup
87
- WebMock.disable_net_connect!
88
- stub_request(:get, 'https://yegor256.github.io/judges/assets/index.css').to_return(body: 'nothing')
89
- stub_request(:get, 'https://yegor256.github.io/judges/assets/index.js').to_return(body: 'nothing')
90
- fb = Factbase.new
91
- f = fb.insert
92
- f.what = 'test issue'
93
- f.when = Time.now
94
- f.ticket = 42
95
- html = File.join(__dir__, '../../temp/colgroup_test.html')
96
- FileUtils.rm_f(html)
97
- Dir.mktmpdir do |d|
98
- factbase_file = File.join(d, 'base.fb')
99
- File.binwrite(factbase_file, fb.export)
100
- Judges::Print.new(Loog::NULL).run(
101
- { 'format' => 'html', 'columns' => 'what,when,ticket' },
102
- [factbase_file, html]
103
- )
104
- end
105
- doc = Nokogiri::HTML(File.read(html))
106
- table = doc.at_css('table#facts')
107
- refute_nil(table, 'Table with id="facts" should exist')
108
- colgroup = table.at_css('colgroup')
109
- refute_nil(colgroup, 'Table should have a colgroup element')
110
- cols = colgroup.css('col')
111
- assert_equal(4, cols.size, 'Should have 4 col elements (3 for columns + 1 for extra)')
112
- assert_equal('w50', cols.last['class'], 'Last col should have class="w50"')
113
- end
114
-
115
- def test_print_all_formats
116
- WebMock.disable_net_connect!
117
- stub_request(:get, 'https://yegor256.github.io/judges/assets/index.css').to_return(body: 'nothing')
118
- stub_request(:get, 'https://yegor256.github.io/judges/assets/index.js').to_return(body: 'nothing')
119
- %w[yaml html xml json].each do |fmt|
120
- Dir.mktmpdir do |d|
121
- f = File.join(d, 'base.fb')
122
- fb = Factbase.new
123
- fb.insert
124
- File.binwrite(f, fb.export)
125
- Judges::Print.new(Loog::NULL).run({ 'format' => fmt, 'auto' => true }, [f])
126
- y = File.join(d, "base.#{fmt}")
127
- assert_path_exists(y)
128
- end
129
- end
130
- end
131
-
132
- def test_print_twice
133
- Dir.mktmpdir do |d|
134
- f = File.join(d, 'base.fb')
135
- fb = Factbase.new
136
- fb.insert
137
- File.binwrite(f, fb.export)
138
- Judges::Print.new(Loog::NULL).run({ 'format' => 'yaml', 'auto' => true }, [f])
139
- y = File.join(d, 'base.yaml')
140
- assert_path_exists(y)
141
- mtime = File.mtime(y)
142
- Judges::Print.new(Loog::NULL).run({ 'format' => 'yaml', 'auto' => true }, [f])
143
- assert_equal(mtime, File.mtime(y))
144
- end
145
- end
146
- end
@@ -1,77 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'factbase'
7
- require 'loog'
8
- require 'webmock/minitest'
9
- require_relative '../../lib/judges'
10
- require_relative '../../lib/judges/commands/pull'
11
- require_relative '../test__helper'
12
-
13
- # Test.
14
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
15
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
16
- # License:: MIT
17
- class TestPull < Minitest::Test
18
- def test_pull_simple_factbase
19
- WebMock.disable_net_connect!
20
- stub_request(:get, 'http://example.org/csrf').to_return(body: 'test-csrf-token')
21
- stub_request(:post, %r{http://example.org/lock/foo}).to_return(status: 302)
22
- stub_request(:get, 'http://example.org/exists/foo').to_return(body: 'yes')
23
- stub_request(:get, 'http://example.org/recent/foo.txt').to_return(body: '42')
24
- stub_request(:get, 'http://example.org/finished/42').to_return(body: 'yes')
25
- stub_request(:get, 'http://example.org/exit/42.txt').to_return(body: '0')
26
- stub_request(:post, %r{http://example.org/unlock/foo}).to_return(status: 302)
27
- fb = Factbase.new
28
- fb.insert.foo = 42
29
- stub_request(:get, 'http://example.org/pull/42.fb').to_return(body: fb.export, headers: {})
30
- Dir.mktmpdir do |d|
31
- file = File.join(d, 'base.fb')
32
- Judges::Pull.new(Loog::NULL).run(
33
- {
34
- 'token' => '000',
35
- 'host' => 'example.org',
36
- 'port' => 80,
37
- 'ssl' => false,
38
- 'wait' => 10,
39
- 'owner' => 'none'
40
- },
41
- ['foo', file]
42
- )
43
- fb = Factbase.new
44
- fb.import(File.binread(file))
45
- end
46
- end
47
-
48
- def test_fail_pull_when_job_is_broken
49
- WebMock.disable_net_connect!
50
- stub_request(:get, 'http://example.org/csrf').to_return(body: 'test-csrf-token')
51
- stub_request(:post, %r{http://example.org/lock/foo}).to_return(status: 302)
52
- stub_request(:get, 'http://example.org/exists/foo').to_return(body: 'yes')
53
- stub_request(:get, 'http://example.org/recent/foo.txt').to_return(body: '42')
54
- stub_request(:get, 'http://example.org/finished/42').to_return(body: 'yes')
55
- stub_request(:get, 'http://example.org/exit/42.txt').to_return(body: '1')
56
- stub_request(:get, 'http://example.org/stdout/42.txt').to_return(body: 'oops, some trouble here')
57
- stub_request(:post, %r{http://example.org/unlock/foo}).to_return(status: 302)
58
- Dir.mktmpdir do |d|
59
- file = File.join(d, 'base.fb')
60
- e =
61
- assert_raises(StandardError) do
62
- Judges::Pull.new(Loog::NULL).run(
63
- {
64
- 'token' => '000',
65
- 'host' => 'example.org',
66
- 'port' => 80,
67
- 'ssl' => false,
68
- 'wait' => 10,
69
- 'owner' => 'none'
70
- },
71
- ['foo', file]
72
- )
73
- end
74
- assert_includes(e.message, 'expire it', e)
75
- end
76
- end
77
- end
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'loog'
7
- require 'webmock/minitest'
8
- require_relative '../../lib/judges'
9
- require_relative '../../lib/judges/commands/push'
10
- require_relative '../test__helper'
11
-
12
- # Test.
13
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
14
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
15
- # License:: MIT
16
- class TestPush < Minitest::Test
17
- def test_push_simple_factbase
18
- WebMock.disable_net_connect!
19
- stub_request(:get, 'https://example.org/csrf').to_return(body: 'test-csrf-token')
20
- stub_request(:post, %r{https://example.org/lock/foo}).to_return(status: 302)
21
- stub_request(:post, %r{https://example.org/unlock/foo}).to_return(status: 302)
22
- stub_request(:put, 'https://example.org/push/foo').to_return(
23
- status: 200, body: '42'
24
- )
25
- Dir.mktmpdir do |d|
26
- file = File.join(d, 'base.fb')
27
- fb = Factbase.new
28
- fb.insert.foo_bar = 42
29
- File.binwrite(file, fb.export)
30
- Judges::Push.new(Loog::NULL).run(
31
- {
32
- 'token' => '000',
33
- 'host' => 'example.org',
34
- 'port' => 443,
35
- 'ssl' => true,
36
- 'owner' => 'none'
37
- },
38
- ['foo', file]
39
- )
40
- Judges::Push.new(Loog::NULL).run(
41
- {
42
- 'token' => '000',
43
- 'host' => 'example.org',
44
- 'port' => 443,
45
- 'ssl' => true,
46
- 'owner' => 'none',
47
- 'zip' => false
48
- },
49
- ['foo', file]
50
- )
51
- end
52
- end
53
-
54
- def test_fails_on_http_error
55
- WebMock.disable_net_connect!
56
- stub_request(:get, 'http://example.org/csrf').to_return(body: 'test-csrf-token')
57
- stub_request(:post, %r{http://example.org/lock/foo}).to_return(status: 302)
58
- stub_request(:put, 'http://example.org/push/foo').to_return(status: 500)
59
- stub_request(:post, %r{http://example.org/unlock/foo}).to_return(status: 302)
60
- Dir.mktmpdir do |d|
61
- file = File.join(d, 'base.fb')
62
- fb = Factbase.new
63
- fb.insert.foo_bar = 42
64
- File.binwrite(file, fb.export)
65
- assert_raises(StandardError) do
66
- Judges::Push.new(Loog::NULL).run(
67
- {
68
- 'token' => '000',
69
- 'host' => 'example.org',
70
- 'port' => 80,
71
- 'ssl' => false,
72
- 'owner' => 'none'
73
- },
74
- ['foo', file]
75
- )
76
- end
77
- end
78
- end
79
- end