From ddea35e23596e32255222a001538571e335055af Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 25 Aug 2013 08:22:20 +0000 Subject: tests: use unix_client in tests to kill some redundant code This should make porting to different Unix socket types easier, too. Much of these tests were written before I decided to implement unix_client originally. --- test/player_integration.rb | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'test/player_integration.rb') diff --git a/test/player_integration.rb b/test/player_integration.rb index 6580194..72f6039 100644 --- a/test/player_integration.rb +++ b/test/player_integration.rb @@ -4,6 +4,7 @@ require './test/helper' require 'dtas/player' require 'dtas/state_file' +require 'dtas/unix_client' require 'yaml' require 'tempfile' require 'shellwords' @@ -46,18 +47,8 @@ module PlayerIntegration end end - module PlayerClient - def preq(args) - args = Shellwords.join(args) if Array === args - send(args, Socket::MSG_EOR) - end - end - def client_socket - s = Socket.new(:AF_UNIX, :SOCK_SEQPACKET, 0) - s.connect(Socket.pack_sockaddr_un(@sock_path)) - s.extend(PlayerClient) - s + DTAS::UNIXClient.new(@sock_path) end def wait_pid_dead(pid, time = 5) @@ -79,8 +70,7 @@ module PlayerIntegration def default_sink_pid(s) default_pid = Tempfile.new(%w(dtas-test .pid)) pf = "echo $$ >> #{default_pid.path}; " - s.send("sink ed default command='#{pf}#@cmd'", Socket::MSG_EOR) - assert_equal "OK", s.readpartial(666) + s.req_ok("sink ed default command='#{pf}#@cmd'") default_pid end @@ -108,13 +98,11 @@ module PlayerIntegration end def dethrottle_decoder(s) - s.send("sink ed default active=false", Socket::MSG_EOR) - assert_equal "OK", s.readpartial(666) + s.req_ok("sink ed default active=false") end def stop_playback(pid_file, s) - s.send("skip", Socket::MSG_EOR) - assert_equal "OK", s.readpartial(666) + s.req_ok("skip") pid = read_pid_file(pid_file) wait_pid_dead(pid) end -- cgit v1.2.3-24-ge0c7