File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,9 @@ def read_input(input_len):
8383 _init_host_interface ()
8484 input_len = int (input_len )
8585 buff = ctypes .create_string_buffer (input_len )
86- return _host_interface .__faasm_read_input (buff , input_len )
86+ _host_interface .__faasm_read_input (buff , input_len )
87+
88+ return buff .value
8789
8890
8991def write_output (output ):
Original file line number Diff line number Diff line change 1+ import unittest
2+ import json
3+ from pyfaasm .core import (
4+ get_input_len ,
5+ read_input ,
6+ set_emulator_message ,
7+ )
8+
9+
10+ class TestInputs (unittest .TestCase ):
11+ def test_input_data (self ):
12+ expected = "blah blah foo bar"
13+ msg = {"user" : "foo" , "function" : "bar" , "input_data" : expected }
14+
15+ set_emulator_message (json .dumps (msg ))
16+
17+ input_len = get_input_len ()
18+ self .assertEqual (input_len , len (expected ))
19+
20+ actual_bytes = read_input (input_len )
21+ actual = actual_bytes .decode ("utf-8" )
22+
23+ self .assertEqual (actual , expected )
24+
25+ def test_empty_input_data (self ):
26+ msg = {"user" : "foo" , "function" : "bar" }
27+
28+ set_emulator_message (json .dumps (msg ))
29+
30+ input_len = get_input_len ()
31+ self .assertEqual (input_len , 0 )
You can’t perform that action at this time.
0 commit comments