diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-23 20:55:47 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-23 20:55:47 -0700 |
commit | b1f0fa4dc98a65dd956ded0eadce3bd9d010d100 (patch) | |
tree | 7bca26963af86947d1986a06a481278ba934e664 /092socket.mu | |
parent | 9da067db49bda56fe339264c48bb7c0c227d17f9 (diff) | |
download | mu-b1f0fa4dc98a65dd956ded0eadce3bd9d010d100.tar.gz |
3573 - client socket tests
This is just the same as tests for a fake file-system.
Diffstat (limited to '092socket.mu')
-rw-r--r-- | 092socket.mu | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/092socket.mu b/092socket.mu index c6418c8d..5e788da2 100644 --- a/092socket.mu +++ b/092socket.mu @@ -28,6 +28,27 @@ def example-handler query:text -> response:text [ reply [abc] ] +# To test client operations, use `assume-resources` with a filename that +# begins with a hostname. (Filenames starting with '/' are assumed to be +# local.) +scenario example-client-test [ + local-scope + assume-resources [ + [example.com/] <- [ + |abc| + ] + ] + run [ + source:&:source:char <- start-reading-from-network resources, [example.com/] + ] + contents:text <- drain source + 10:@:char/raw <- copy *contents + memory-should-contain [ + 10:array:character <- [abc +] + ] +] + type request-handler = (recipe text -> text) def serve-one-request socket:num, request-handler:request-handler [ @@ -64,8 +85,8 @@ def start-reading-from-network resources:&:resources, uri:text -> contents:&:sou start-running receive-from-socket socket, sink return } - # todo: fake network - return 0/not-found + # fake network + contents <- start-reading-from-fake-resources resources, uri ] def request-socket socket:num, s:text -> socket:num [ |