about summary refs log tree commit homepage
path: root/examples/rails_app-2.3.4/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-13 01:01:58 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-13 01:01:58 -0800
commiteead1a80dd5fdca57cc8aa0333d249415ba2d85a (patch)
tree34578a70f39dc6627831c1fa73031fedfacba15d /examples/rails_app-2.3.4/test
parentf4b44763fa6802543f7d1590719e5aed21e120cd (diff)
downloadupr-eead1a80dd5fdca57cc8aa0333d249415ba2d85a.tar.gz
example/rails_app-2.3.4: UprStatus unit tests
UprStatus.incr now returns the value incremented to
be compatible with Upr::Monitor.incr
Diffstat (limited to 'examples/rails_app-2.3.4/test')
-rw-r--r--examples/rails_app-2.3.4/test/fixtures/upr_statuses.yml22
-rw-r--r--examples/rails_app-2.3.4/test/unit/upr_status_test.rb41
2 files changed, 63 insertions, 0 deletions
diff --git a/examples/rails_app-2.3.4/test/fixtures/upr_statuses.yml b/examples/rails_app-2.3.4/test/fixtures/upr_statuses.yml
new file mode 100644
index 0000000..2859c5f
--- /dev/null
+++ b/examples/rails_app-2.3.4/test/fixtures/upr_statuses.yml
@@ -0,0 +1,22 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+chunky:
+  upid: one
+  length: nil
+  seen: 0
+  time: 0
+length:
+  upid: two
+  length: 5
+  seen: 0
+  time: 0
+done:
+  upid: done
+  length: 5
+  seen: 5
+  time: 0
+errored:
+  upid: errored
+  length: 5
+  seen: -1
+  time: 0
diff --git a/examples/rails_app-2.3.4/test/unit/upr_status_test.rb b/examples/rails_app-2.3.4/test/unit/upr_status_test.rb
new file mode 100644
index 0000000..d62d869
--- /dev/null
+++ b/examples/rails_app-2.3.4/test/unit/upr_status_test.rb
@@ -0,0 +1,41 @@
+require 'test_helper'
+
+class UprStatusTest < ActiveSupport::TestCase
+  # Replace this with your real tests.
+  test "start with length" do
+    assert_kind_of UprStatus, UprStatus.start('abcde', 5)
+  end
+
+  test "start without length" do
+    assert_kind_of UprStatus, UprStatus.start('abcde', nil)
+  end
+
+  test "incr from start" do
+    assert_nothing_raised { UprStatus.incr('two', 2) }
+    assert_equal 2, UprStatus.read('two').seen
+  end
+
+  test "errored" do
+    assert UprStatus.read('errored').error?
+  end
+
+  test "errored incr no-op" do
+    assert UprStatus.incr('errored', 6)
+    assert UprStatus.read('errored').error?
+  end
+
+  test "finish" do
+    assert_kind_of UprStatus, UprStatus.finish('two')
+    assert UprStatus.read('two').done?
+  end
+
+  test "done?" do
+    assert UprStatus.read('done').done?
+  end
+
+  test "error!" do
+    assert_kind_of UprStatus, UprStatus.error!('two')
+    assert UprStatus.read('two').error?
+  end
+
+end