Make all tests pass

This commit is contained in:
Aoran Zeng 2024-09-04 19:47:06 +08:00
parent 6b96e4f063
commit f211b72691
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98

View File

@ -11,7 +11,7 @@
use v5.38;
use Test::More;
my $version_str = qr|Written by Aoran Zeng, Heng Guo and contributors|;
my $version_str = qr|chsrc .*\nCopyright .*\nLicense GPLv3\+: GNU GPL version 3 or later|;
like `./chsrc -v`, $version_str, 'chsrc -v';
like `./chsrc --version`, $version_str, 'chsrc --version';
like `./chsrc version`, $version_str, 'chsrc version';
@ -25,7 +25,7 @@ like `./chsrc`, $help_str, 'chsrc';
=begin
测试 chsrc list
=cut
my $list_str = qr/mirrorz\s*MirrorZ\s*.*/;
my $list_str = qr/mirrorz\s*MirrorZ\s*.*\ntuna\s*TUNA/;
like `./chsrc ls`, $list_str, 'chsrc ls';
like `./chsrc list mirrors`, $list_str, 'chsrc list mirrors';
like `./chsrc list os`, qr/debian\s*ubuntu/, 'chsrc list os';
@ -41,11 +41,19 @@ like `./chsrc get -no-color 2>&1`, $get_null, 'chsrc get -no-color';
my $fake_target_name = qr/暂不支持的换源目标/;
like `./chsrc get fake_target_name 2>&1`, $fake_target_name, 'chsrc get fake_target_name';
my $has_ruby = system 'ruby1 -v';
if ($has_ruby == 0) {
say "Ruby exists. Go on testing.";
} else {
say "No Ruby. End testing.";
done_testing;
exit 0;
}
my $get_ruby = qr/gem sources/;
like `./chsrc get ruby`, $get_ruby, 'chsrc get ruby';
=begin
测试 chsrc measure
=cut
@ -57,20 +65,19 @@ like `./chsrc measure ruby`, $measure_ruby, 'chsrc measure ruby';
=begin
测试 chsrc set 以及 chsrc reset
=cut
my $set_ruby = "换源完成,感谢镜像提供方";
my $set_ruby_abcd = "";
my $set_ruby_first = "换源完成,感谢镜像提供方";
my $reset_ruby = "将重置为上游默认源.*Upstream";
my $set_ruby_tencent = "换源完成,感谢镜像提供方.*腾讯软件源";
my $set_ruby_locally = "bundle config --local";
my $set_ruby_abcd = qr/镜像站.*不存在/;
my $set_ruby_first = qr/全自动换源完成, 感谢镜像提供方/;
my $set_ruby = qr/全自动换源完成, 感谢镜像提供方/;
my $reset_ruby = qr/将重置为上游默认源.*Upstream/s;
my $set_ruby_rubychina = qr/Ruby China 社区/;
my $set_ruby_locally = qr/bundle config --local/;
like `./chsrc set ruby`, qr/$set_ruby/, 'chsrc set ruby';
# like `./chsrc set ruby abcd`, qr/$set_ruby_abcd/, 'chsrc set ruby abcd';
like `./chsrc set ruby first`, qr/$set_ruby_first/, 'chsrc set ruby first';
like `./chsrc reset ruby`, qr/$reset_ruby/s, 'chsrc reset ruby';
like `./chsrc set ruby tencent`, qr/$set_ruby_tencent/, 'chsrc set ruby tencent';
like `./chsrc set -local ruby tencent`, qr/$set_ruby_locally/, 'chsrc set -local ruby tencent';
like `./chsrc set ruby abcd 2>&1`, $set_ruby_abcd, 'chsrc set ruby abcd';
like `./chsrc set ruby first`, $set_ruby_first, 'chsrc set ruby first';
like `./chsrc set ruby`, $set_ruby, 'chsrc set ruby';
like `./chsrc reset ruby`, $reset_ruby, 'chsrc reset ruby';
like `./chsrc set ruby rubychina`, $set_ruby_rubychina, 'chsrc set ruby rubychina';
like `./chsrc set -local ruby first`, $set_ruby_locally, 'chsrc set -local ruby first';
done_testing;