test/commands/test_remote.rb in zold-0.31.8 vs test/commands/test_remote.rb in zold-0.31.9

- old
+ new

@@ -1,8 +1,8 @@ # frozen_string_literal: true -# Copyright (c) 2018-2023 Zerocracy +# Copyright (c) 2018-2024 Zerocracy # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the 'Software'), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell @@ -32,11 +32,11 @@ require_relative '../../lib/zold/log' require_relative '../../lib/zold/commands/remote' # REMOTE test. # Author:: Yegor Bugayenko (yegor256@gmail.com) -# Copyright:: Copyright (c) 2018 Yegor Bugayenko +# Copyright:: Copyright (c) 2018-2024 Zerocracy # License:: MIT class TestRemote < Zold::Test def test_updates_remote Dir.mktmpdir do |dir| remotes = Zold::Remotes.new(file: File.join(dir, 'a/b/c/remotes')) @@ -65,11 +65,11 @@ stub_request(:get, 'https://rubygems.org/api/v1/versions/zold/latest.json').to_return( status: 200, headers: {}, body: '{"version": "0.0.0"}' ) - cmd = Zold::Remote.new(remotes: remotes, log: test_log) + cmd = Zold::Remote.new(remotes: remotes, log: fake_log) cmd.run(%w[remote clean]) assert(remotes.all.empty?) cmd.run(['remote', 'add', zero.host, zero.port.to_s, '--skip-ping']) cmd.run(%w[remote add localhost 2 --skip-ping]) assert_equal(2, remotes.all.count) @@ -124,20 +124,20 @@ body: { version: Zold::VERSION, score: zero.to_h }.to_json ) - cmd = Zold::Remote.new(remotes: remotes, log: test_log) + cmd = Zold::Remote.new(remotes: remotes, log: fake_log) winners = cmd.run(%w[remote elect --ignore-score-value]) assert_equal(1, winners.count) end end def test_resets_remotes Dir.mktmpdir do |dir| remotes = Zold::Remotes.new(file: File.join(dir, 'remotes.txt')) - Zold::Remote.new(remotes: remotes, log: test_log).run(%w[remote reset]) + Zold::Remote.new(remotes: remotes, log: fake_log).run(%w[remote reset]) end end def test_remote_trim_with_tolerate Dir.mktmpdir do |dir| @@ -162,11 +162,11 @@ stub_request(:get, 'https://rubygems.org/api/v1/versions/zold/latest.json').to_return( status: 200, body: '{"version": "0.0.0"}' ) stub_request(:get, 'http://localhost:8883/remotes').to_return(status: 404) - cmd = Zold::Remote.new(remotes: remotes, log: test_log) + cmd = Zold::Remote.new(remotes: remotes, log: fake_log) cmd.run(%w[remote clean]) assert(remotes.all.empty?) cmd.run(['remote', 'add', score.host, score.port.to_s, '--skip-ping']) cmd.run(['remote', 'update', '--ignore-score-weakness', '--skip-ping']) assert_equal(2, remotes.all.count) @@ -177,11 +177,11 @@ end def test_select_selects_the_strongest_nodes Dir.mktmpdir do |dir| remotes = Zold::Remotes.new(file: File.join(dir, 'remotes.txt')) - cmd = Zold::Remote.new(remotes: remotes, log: test_log) + cmd = Zold::Remote.new(remotes: remotes, log: fake_log) (1..11).each do |i| cmd.run(%W[remote add localhost #{i} --skip-ping]) remotes.rescore('localhost', i, i) i.times { remotes.error('localhost', i) } end @@ -195,11 +195,11 @@ def test_select_respects_max_nodes_option Dir.mktmpdir do |dir| remotes = Zold::Remotes.new(file: File.join(dir, 'remotes.txt')) remotes.masters zero = Zold::Score::ZERO - cmd = Zold::Remote.new(remotes: remotes, log: test_log) + cmd = Zold::Remote.new(remotes: remotes, log: fake_log) (5000..5010).each do |port| stub_request(:get, "http://#{zero.host}:#{zero.port}/remotes").to_return( status: 200, body: { version: Zold::VERSION, @@ -224,20 +224,20 @@ end def test_sets_masters Dir.mktmpdir do |dir| remotes = Zold::Remotes.new(file: File.join(dir, 'remotes.txt')) - cmd = Zold::Remote.new(remotes: remotes, log: test_log) + cmd = Zold::Remote.new(remotes: remotes, log: fake_log) cmd.run(%w[remote masters]) assert(!remotes.all.empty?) end end def test_select_doesnt_touch_masters Dir.mktmpdir do |dir| remotes = Zold::Remotes.new(file: File.join(dir, 'remotes.txt')) - cmd = Zold::Remote.new(remotes: remotes, log: test_log) + cmd = Zold::Remote.new(remotes: remotes, log: fake_log) cmd.run(%w[remote masters]) cmd.run(%w[remote select --max-nodes=0]) assert(!remotes.all.empty?) end end @@ -253,10 +253,10 @@ version: Zold::VERSION, score: zero.to_h, all: [] }.to_json ) - cmd = Zold::Remote.new(remotes: remotes, log: test_log) + cmd = Zold::Remote.new(remotes: remotes, log: fake_log) cmd.run(['remote', 'add', zero.host, zero.port.to_s, '--skip-ping']) cmd.run(['remote', 'update', '--ignore-score-weakness', '--depth=10']) assert_equal(1, remotes.all.count) assert_requested(get, times: 1) end