You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2019/11/28 20:39:09 UTC
[whimsy] branch master updated: Add test of ASF::ICLAFiles
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 4b56298 Add test of ASF::ICLAFiles
4b56298 is described below
commit 4b56298eda9a3c53df6fdbc813f3b6a113ffde85
Author: Sebb <se...@apache.org>
AuthorDate: Thu Nov 28 20:38:51 2019 +0000
Add test of ASF::ICLAFiles
---
lib/spec/lib/icla_spec.rb | 42 ++++++++++++++++++++++++++++++++++++++++++
lib/spec/spec_helper.rb | 8 ++++++++
lib/test/svn/iclas.txt | 6 ++++++
lib/test/svn/iclas/abc.pdf | 0
lib/test/svn/iclas/abcd.pdf | 0
lib/whimsy/asf/config.rb | 4 ++++
6 files changed, 60 insertions(+)
diff --git a/lib/spec/lib/icla_spec.rb b/lib/spec/lib/icla_spec.rb
new file mode 100644
index 0000000..3ff6c7d
--- /dev/null
+++ b/lib/spec/lib/icla_spec.rb
@@ -0,0 +1,42 @@
+# encoding: utf-8
+# frozen_string_literal: true
+
+require 'spec_helper'
+require 'whimsy/asf'
+
+set_root # need access to listing file
+
+set_svn 'iclas' # only works with test data as real entry names should not be published
+# Test data:
+# ab/ abc.pdf abcd/ abcd.pdf abcde/
+
+describe ASF::ICLAFiles do
+
+ describe "ASF::ICLAFiles.match_claRef" do
+ it "should return nil for 'xyz'" do
+ res = ASF::ICLAFiles.match_claRef('xyz')
+ expect(res).to equal(nil)
+ end
+ it "should return nil for 'a'" do
+ res = ASF::ICLAFiles.match_claRef('a')
+ expect(res).to equal(nil)
+ end
+ it "should return 'ab' for 'ab'" do
+ res = ASF::ICLAFiles.match_claRef('ab')
+ expect(res).to eq('ab')
+ end
+ it "should return 'abc.pdf' for 'abc'" do
+ res = ASF::ICLAFiles.match_claRef('abc')
+ expect(res).to eq('abc.pdf')
+ end
+ it "should return 'abcd' for 'abcd'" do
+ res = ASF::ICLAFiles.match_claRef('abcd')
+ expect(res).to eq('abcd')
+ end
+ it "should return 'abcde' for 'abcde'" do
+ res = ASF::ICLAFiles.match_claRef('abcde')
+ expect(res).to eq('abcde')
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/lib/spec/spec_helper.rb b/lib/spec/spec_helper.rb
index c0bbc94..de352e3 100644
--- a/lib/spec/spec_helper.rb
+++ b/lib/spec/spec_helper.rb
@@ -13,6 +13,14 @@ else
TEST_DATA = false
end
+def set_root
+ ASF::Config.setroot File.expand_path("../test", __dir__)
+end
+
+def set_svn(name)
+ ASF::SVN[name] = File.expand_path("../test/svn/#{name}", __dir__)
+end
+
if TEST_DATA
puts "TEST_DATA=#{TEST_DATA}"
else
diff --git a/lib/test/svn/iclas.txt b/lib/test/svn/iclas.txt
new file mode 100644
index 0000000..69cdc0d
--- /dev/null
+++ b/lib/test/svn/iclas.txt
@@ -0,0 +1,6 @@
+0
+ab/
+abc.pdf
+abcd/
+abcd.pdf
+abcde/
diff --git a/lib/test/svn/iclas/abc.pdf b/lib/test/svn/iclas/abc.pdf
new file mode 100644
index 0000000..e69de29
diff --git a/lib/test/svn/iclas/abcd.pdf b/lib/test/svn/iclas/abcd.pdf
new file mode 100644
index 0000000..e69de29
diff --git a/lib/whimsy/asf/config.rb b/lib/whimsy/asf/config.rb
index 5fc8d50..09d3431 100644
--- a/lib/whimsy/asf/config.rb
+++ b/lib/whimsy/asf/config.rb
@@ -119,6 +119,10 @@ module ASF
def self.root
@root
end
+ # For testing only!!
+ def self.setroot(path)
+ @root = path
+ end
end
end