whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Add basic tests for ASF::Site
Date Thu, 24 Oct 2019 14:21:19 GMT
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 a61e83a  Add basic tests for ASF::Site
a61e83a is described below

commit a61e83a1e68650f1ce7f721a5a684bbc422ba49a
Author: Sebb <sebb@apache.org>
AuthorDate: Thu Oct 24 15:21:15 2019 +0100

    Add basic tests for ASF::Site
---
 lib/spec/lib/site_spec.rb              | 53 ++++++++++++++++++++++++++++++++++
 lib/spec/spec_helper.rb                |  3 +-
 lib/test/svn/board/committee-info.yaml | 17 +++++++++++
 3 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/lib/spec/lib/site_spec.rb b/lib/spec/lib/site_spec.rb
new file mode 100644
index 0000000..f1cb5bc
--- /dev/null
+++ b/lib/spec/lib/site_spec.rb
@@ -0,0 +1,53 @@
+# encoding: utf-8
+# frozen_string_literal: true
+# test ASF::Site
+
+require 'spec_helper'
+require 'whimsy/asf'
+
+describe ASF::Site do
+
+  describe "ASF::Site.find" do
+    it "should return hash for 'httpd'" do
+      res = ASF::Site.find('httpd')
+      expect(res.class).to eq(Hash) 
+      expect(res[:site]).to match(%r{https?://httpd\.apache\.org/?}) 
+    end
+
+    it "should return nil for 'z-z-z'" do
+      res = ASF::Site.find('z-z-z')
+      expect(res.class).to eq(NilClass) 
+    end
+
+    it "should return hash for 'httpd Committee'" do
+      cttee = ASF::Committee.find('HTTP Server')
+      res = ASF::Site.find(cttee)
+      expect(res.class).to eq(Hash) 
+      expect(res[:site]).to match(%r{https?://httpd\.apache\.org/?})
+    end
+  end
+
+  describe "ASF::Site.appendtlp" do
+    board = ASF::SVN.find('board')
+    file = File.join(board, 'committee-info.yaml')
+    input = File.read(file)
+    it "should fail for 'httpd'" do
+      res = nil
+      expect { res = ASF::Site.appendtlp(input,'httpd','description') }.to output("_WARN
Entry for 'httpd' already exists under :tlps\n").to_stderr
+      expect(res).to equal(input)
+    end    
+    pmc = 'a-b-c'
+    it "should succeed for '#{pmc}'" do
+      res = nil
+      desc = 'Description of A-B-C'
+      expect { res = ASF::Site.appendtlp(input,pmc,desc) }.to output("").to_stderr
+      expect(res).not_to eq(input)
+      tlps = YAML.load(res)[:tlps]
+      abc = tlps[pmc]
+      expect(abc.class).to eq(Hash) 
+      expect(abc[:site]).to match(%r{https?://#{pmc}\.apache\.org/?}) 
+      expect(abc[:description]).to eq(desc) 
+    end    
+  end
+
+end
\ No newline at end of file
diff --git a/lib/spec/spec_helper.rb b/lib/spec/spec_helper.rb
index 4041bea..e46b330 100644
--- a/lib/spec/spec_helper.rb
+++ b/lib/spec/spec_helper.rb
@@ -2,10 +2,11 @@ $LOAD_PATH.unshift '/srv/whimsy/lib'
 
 require 'whimsy/asf'
 # Override with test data if there is no checkout available (allows local use)
-if ENV['RAKE_TEST'] == 'TRUE' or not ASF::SVN.find('apmail_bin')
+if ENV['RAKE_TEST'] == 'TRUE' or not (ASF::SVN.find('apmail_bin') and ASF::SVN.find('board'))
   TEST_DATA = true # Test data is smaller so some tests need adjusting
   puts "Overriding data directories"
   ASF::SVN['apmail_bin'] = File.expand_path('../test/svn/apmail_bin', __dir__)
+  ASF::SVN['board'] = File.expand_path('../test/svn/board', __dir__)
   ASF::Config[:subscriptions] = File.expand_path('../test/subscriptions', __dir__)
 else
   TEST_DATA = false
diff --git a/lib/test/svn/board/committee-info.yaml b/lib/test/svn/board/committee-info.yaml
new file mode 100644
index 0000000..c08fa1a
--- /dev/null
+++ b/lib/test/svn/board/committee-info.yaml
@@ -0,0 +1,17 @@
+# Test data
+
+---
+:name2id:
+  "HTTP Server":                      httpd
+
+:cttees:
+  comdev:
+    :site: http://community.apache.org/
+    :description: Resources to help people become involved with Apache projects
+
+:tlps:
+  httpd:
+    :site: http://httpd.apache.org/
+    :description: Apache Web Server (httpd)
+...
+# ends
\ No newline at end of file


Mime
View raw message