From e3b1fd53636074478d2ed240896f62800c241cff Mon Sep 17 00:00:00 2001 From: Jon Jagger Date: Thu, 16 Jan 2020 08:32:45 +0000 Subject: [PATCH] When colour==faulty return rag_lambda and error.message in lined format --- app/src/traffic_light.rb | 10 ++++----- test_server/feature_traffic_light_test.rb | 26 +++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/src/traffic_light.rb b/app/src/traffic_light.rb index 2c35831b..4b75b40e 100644 --- a/app/src/traffic_light.rb +++ b/app/src/traffic_light.rb @@ -24,8 +24,8 @@ def traffic_light(image_name, id, rag_src, stdout, stderr, status) 'image_name' => image_name, 'id' => id, 'info' => 'eval(rag_lambda) raised an exception', - 'message' => error.message, - 'rag_lambda' => rag_src + 'message' => error.message.lines, + 'rag_lambda' => rag_src.lines } } end @@ -41,8 +41,8 @@ def traffic_light(image_name, id, rag_src, stdout, stderr, status) 'image_name' => image_name, 'id' => id, 'info' => 'rag_lambda.call raised an exception', - 'message' => error.message, - 'rag_lambda' => rag_src + 'message' => error.message.lines, + 'rag_lambda' => rag_src.lines } } end @@ -54,7 +54,7 @@ def traffic_light(image_name, id, rag_src, stdout, stderr, status) 'image_name' => image_name, 'id' => id, 'info' => "rag_lambda.call is '#{colour}' which is not 'red'|'amber'|'green'", - 'rag_lambda' => rag_src + 'rag_lambda' => rag_src.lines } } end diff --git a/test_server/feature_traffic_light_test.rb b/test_server/feature_traffic_light_test.rb index 10847c06..203e1cd1 100644 --- a/test_server/feature_traffic_light_test.rb +++ b/test_server/feature_traffic_light_test.rb @@ -89,8 +89,8 @@ def self.hex_prefix assert_equal image_stub, diagnostic['image_name'], :image_name assert_equal id, diagnostic['id'], :id assert_equal expected_info, diagnostic['info'], :info - assert diagnostic['message'].start_with?(expected_message), :message - assert_equal stub, diagnostic['rag_lambda'], :rag_lambda + assert diagnostic['message'][0].start_with?(expected_message), :message + assert_equal stub.lines, diagnostic['rag_lambda'], :rag_lambda end # - - - - - - - - - - - - - - - - - @@ -113,8 +113,8 @@ def self.hex_prefix assert_equal image_stub, diagnostic['image_name'], :image_name assert_equal id, diagnostic['id'], :id assert_equal expected_info, diagnostic['info'], :info - assert_equal expected_message, diagnostic['message'], :message - assert_equal stub, diagnostic['rag_lambda'], :rag_lambda + assert_equal [expected_message], diagnostic['message'], :message + assert_equal stub.lines, diagnostic['rag_lambda'], :rag_lambda end # - - - - - - - - - - - - - - - - - @@ -137,7 +137,7 @@ def self.hex_prefix assert_equal id, diagnostic['id'], :id assert_equal expected_info, diagnostic['info'], :info assert_nil diagnostic['message'], :message - assert_equal stub, diagnostic['rag_lambda'], :rag_lambda + assert_equal stub.lines, diagnostic['rag_lambda'], :rag_lambda end # - - - - - - - - - - - - - - - - - @@ -160,8 +160,8 @@ def self.hex_prefix assert_equal image_stub, diagnostic['image_name'], :image_name assert_equal id, diagnostic['id'], :id assert_equal expected_info, diagnostic['info'], :info - assert_equal expected_message, diagnostic['message'], :message - assert_equal stub, diagnostic['rag_lambda'], :rag_lambda + assert_equal [expected_message], diagnostic['message'], :message + assert_equal stub.lines, diagnostic['rag_lambda'], :rag_lambda end # - - - - - - - - - - - - - - - - - @@ -184,8 +184,8 @@ def self.hex_prefix assert_equal image_stub, diagnostic['image_name'], :image_name assert_equal id, diagnostic['id'], :id assert_equal expected_info, diagnostic['info'], :info - assert_equal expected_message, diagnostic['message'], :message - assert_equal stub, diagnostic['rag_lambda'], :rag_lambda + assert_equal [expected_message], diagnostic['message'], :message + assert_equal stub.lines, diagnostic['rag_lambda'], :rag_lambda end # - - - - - - - - - - - - - - - - - @@ -203,8 +203,8 @@ def self.hex_prefix assert_equal image_stub, diagnostic['image_name'], :image_name assert_equal id, diagnostic['id'], :id assert_equal expected_info, diagnostic['info'], :info - assert diagnostic['message'].include?(expected_message), :message - assert_equal stub, diagnostic['rag_lambda'], :rag_lambda + assert diagnostic['message'][0].include?(expected_message), :message + assert_equal stub.lines, diagnostic['rag_lambda'], :rag_lambda end # - - - - - - - - - - - - - - - - - @@ -222,8 +222,8 @@ def self.hex_prefix assert_equal image_stub, diagnostic['image_name'], :image_name assert_equal id, diagnostic['id'], :id assert_equal expected_info, diagnostic['info'], :info - assert_equal expected_message, diagnostic['message'], :message - assert_equal stub, diagnostic['rag_lambda'], :rag_lambda + assert_equal [expected_message], diagnostic['message'], :message + assert_equal stub.lines, diagnostic['rag_lambda'], :rag_lambda end private