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 2016/04/05 02:02:50 UTC

[whimsy] branch master updated: Unit test helper module - gets previous status from file

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  596e354   Unit test helper module - gets previous status from file
596e354 is described below

commit 596e354f48c7d4d2afbb6ad98858d0c9b0d0ede8
Author: Sebb <se...@apache.org>
AuthorDate: Tue Apr 5 01:02:41 2016 +0100

    Unit test helper module - gets previous status from file
---
 www/status/monitors/unit_test.rb | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/www/status/monitors/unit_test.rb b/www/status/monitors/unit_test.rb
new file mode 100644
index 0000000..37b2b0d
--- /dev/null
+++ b/www/status/monitors/unit_test.rb
@@ -0,0 +1,13 @@
+# unit test helper
+
+require 'json'
+
+# fetch the status file and extract the previous sample, then call the method
+# the same string is used to extract the sample and call the method
+def runtest(method_name)
+  status_file = File.expand_path('../../status.json', __FILE__)
+  baseline = JSON.parse(File.read(status_file)) rescue {}
+  baseline['data'] = {} unless baseline['data'].instance_of? Hash
+  previous = baseline['data'][method_name] || {mtime: Time.at(0)}
+  puts JSON.pretty_generate(Monitor.send(method_name, previous))
+end

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].