From 31506109ffee39e82b71065bdab5eb197dd13e45 Mon Sep 17 00:00:00 2001 From: Jordan Sissel Date: Sat, 3 Dec 2022 18:09:45 -0800 Subject: [PATCH] Add test coverage for debian version field validation For #1847 --- spec/fpm/package/deb_spec.rb | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/spec/fpm/package/deb_spec.rb b/spec/fpm/package/deb_spec.rb index d98e24fb99..31179aa591 100644 --- a/spec/fpm/package/deb_spec.rb +++ b/spec/fpm/package/deb_spec.rb @@ -127,9 +127,28 @@ end context "when validating the version field" do - pending "it should reject invalid versions" - pending "it should convert v-prefixed-but-otherwise-valid versions" - pending "it should accept valid versions" + [ "_", "1_2", "abc def", "%", "1^a"].each do |v| + it "should reject as invalid, '#{v}'" do + subject.version = v + insist { subject.version }.raises FPM::InvalidPackageConfiguration + end + end + + [ "1", "1.2", "1.2.3", "20200101", "1~beta", "1whatever"].each do |v| + it "should accept '#{v}'" do + subject.version = v + + # should not raise exception + insist { subject.version } == v + end + + it "should remove a leading 'v' from v#{v} and still accept it" do + subject.version = "v#{v}" + + # should not raise exception + insist { subject.version } == v + end + end end describe "#output" do