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: Unit test helper module - gets previous status from file
Date Tue, 05 Apr 2016 00:02:50 GMT
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 <sebb@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" <commits@whimsical.apache.org>'].

Mime
View raw message