unicorn.git  about / heads / tags
Rack HTTP server for Unix and fast clients
blob 37c6fa71e61f6770fc1b09628c11e1363cd49509 676 bytes (raw)
$ git show v1.1.1:t/t0005-working_directory_app.rb.sh	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
#!/bin/sh
. ./test-lib.sh

t_plan 4 "fooapp.rb inside alt working_directory"

t_begin "setup and start" && {
	unicorn_setup
	rm -rf $t_pfx.app
	mkdir $t_pfx.app

	cat > $t_pfx.app/fooapp.rb <<\EOF
class Fooapp
  def self.call(env)
    [ 200, [%w(Content-Type text/plain), %w(Content-Length 2)], %w(HI) ]
  end
end
EOF
	# the whole point of this exercise
	echo "working_directory '$t_pfx.app'" >> $unicorn_config
	cd /
	unicorn -D -c $unicorn_config -I. fooapp.rb
	unicorn_wait_start
}

t_begin "hit with curl" && {
	body=$(curl -sSf http://$listen/)
}

t_begin "killing succeeds" && {
	kill $unicorn_pid
}

t_begin "response body expected" && {
	test x"$body" = xHI
}

t_done

git clone https://yhbt.net/unicorn.git