Permalink
Browse files

adding first basic test

  • Loading branch information...
1 parent f19b59b commit 0db82089c521e9f78ec1bb8d1b36de469d2df524 @romand romand committed Apr 10, 2012
Showing with 38 additions and 0 deletions.
  1. +1 −0 test/hello.rb
  2. +37 −0 test/test_basic.rb
View
@@ -0,0 +1 @@
+puts "hello"
View
@@ -0,0 +1,37 @@
+require './lib/iron_worker_ng.rb'
+require 'test/unit'
+
+class BasicTest < Test::Unit::TestCase
+ attr_accessor :client
+
+ def setup
+ IronWorkerNG::Logger.logger.level = ::Logger::DEBUG
+
+ token, project_id = [ ENV['IRON_IO_TOKEN'], ENV['IRON_IO_PROJECT_ID'] ]
+ raise("please set $IRON_IO_TOKEN and $IRON_IO_PROJECT_ID " +
+ "environment variables") unless token and project_id
+
+ @client = IronWorkerNG::Client.new(:token => token,
+ :project_id => project_id )
+ end
+
+ def test_basic
+ code = IronWorkerNG::Code::Ruby.new('test_basic')
+ code.merge_worker(File.dirname(__FILE__) + '/hello.rb')
+ client.codes_create(code)
+ task_id = client.tasks_create('test_basic').id
+ client.tasks_wait_for(task_id)
+ log = client.tasks_log(task_id)
+ assert_equal( "hello\n", log, "worker stdout is in log" )
+ end
+
+ def test_30_codes
+ 31.times do |i|
+ code = IronWorkerNG::Code::Ruby.new("test_30_codes_code#{i}")
+ code.merge_worker(File.dirname(__FILE__) + '/hello.rb')
+ client.codes_create(code)
+ end
+ assert_equal( 31, client.codes_list.size )
+ end
+
+end

0 comments on commit 0db8208

Please sign in to comment.