httpotemkin 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/client.rb +3 -13
- data/lib/containers.rb +9 -1
- data/lib/version.rb +1 -1
- data/spec/system/client_spec.rb +15 -0
- data/spec/system/hello_world_spec.rb +6 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48d695b887bf805db229dfd7b257639a3f98af12
|
4
|
+
data.tar.gz: d1469f40788c40ad3fd2944cf938895b5d886ca1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d2145a1c62b5c6fd0285596d1e0b1e39344712d7058fe099c473412c6a4106dc1cb5b1422b2f55a334e4a1d0780f00af63f54e39e041d502d71e3b4fd9ab4ad
|
7
|
+
data.tar.gz: fb127a608dd4192ce60600aca6691723dd8ce9583878fa8aeff487669f420e100d23701a6d550fc0a1d21c6bf7f8c4f9ac1c2b09996c63ad9a51ff90968a7ff2
|
data/CHANGELOG.md
CHANGED
data/lib/client.rb
CHANGED
@@ -1,23 +1,13 @@
|
|
1
1
|
module Httpotemkin
|
2
2
|
class Client
|
3
|
+
attr_reader :out, :err, :exit_code
|
4
|
+
|
3
5
|
def initialize(containers)
|
4
6
|
@containers = containers
|
5
7
|
end
|
6
8
|
|
7
9
|
def execute(cmd, working_directory: nil)
|
8
|
-
@out = @containers.exec_client(cmd, working_directory: working_directory)
|
9
|
-
end
|
10
|
-
|
11
|
-
def exit_code
|
12
|
-
0
|
13
|
-
end
|
14
|
-
|
15
|
-
def out
|
16
|
-
@out
|
17
|
-
end
|
18
|
-
|
19
|
-
def err
|
20
|
-
""
|
10
|
+
@out, @err, @exit_code = @containers.exec_client(cmd, working_directory: working_directory)
|
21
11
|
end
|
22
12
|
|
23
13
|
def inject_tarball(filename)
|
data/lib/containers.rb
CHANGED
@@ -97,7 +97,15 @@ module Httpotemkin
|
|
97
97
|
cmd += client_cmd
|
98
98
|
end
|
99
99
|
@out.puts cmd.join(" ")
|
100
|
-
|
100
|
+
begin
|
101
|
+
out, err = Cheetah.run(cmd, stdout: :capture, stderr: :capture)
|
102
|
+
exit_code = 0
|
103
|
+
rescue Cheetah::ExecutionFailed => e
|
104
|
+
out = e.stdout
|
105
|
+
err = e.stderr
|
106
|
+
exit_code = e.status.exitstatus
|
107
|
+
end
|
108
|
+
return out, err, exit_code
|
101
109
|
end
|
102
110
|
|
103
111
|
def links
|
data/lib/version.rb
CHANGED
data/spec/system/client_spec.rb
CHANGED
@@ -67,4 +67,19 @@ describe "client" do
|
|
67
67
|
expect(client.err.empty?).to be(true)
|
68
68
|
end
|
69
69
|
end
|
70
|
+
|
71
|
+
it "captures stderr" do
|
72
|
+
out = double
|
73
|
+
allow(out).to receive(:puts)
|
74
|
+
|
75
|
+
test = Httpotemkin::Test.new(out: out)
|
76
|
+
|
77
|
+
test.run do |client|
|
78
|
+
client.execute(["ls", "iamnothere"])
|
79
|
+
|
80
|
+
expect(client.exit_code).to eq(2)
|
81
|
+
expect(client.out).to eq("")
|
82
|
+
expect(client.err).to eq("ls: cannot access iamnothere: No such file or directory\n")
|
83
|
+
end
|
84
|
+
end
|
70
85
|
end
|
@@ -11,11 +11,11 @@ describe "hello world" do
|
|
11
11
|
|
12
12
|
test.run do |client|
|
13
13
|
sleep 2
|
14
|
-
client.execute(["curl", "server/hello"])
|
14
|
+
client.execute(["curl", "-s", "server/hello"])
|
15
15
|
|
16
16
|
expect(client.exit_code).to eq(0)
|
17
17
|
expect(client.out).to eq("world\n")
|
18
|
-
expect(client.err
|
18
|
+
expect(client.err).to eq("")
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -31,19 +31,19 @@ describe "hello world" do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "answers once" do
|
34
|
-
@client.execute(["curl", "server/hello"])
|
34
|
+
@client.execute(["curl", "-s", "server/hello"])
|
35
35
|
|
36
36
|
expect(@client.exit_code).to eq(0)
|
37
37
|
expect(@client.out).to eq("world\n")
|
38
|
-
expect(@client.err
|
38
|
+
expect(@client.err).to eq("")
|
39
39
|
end
|
40
40
|
|
41
41
|
it "answers twice" do
|
42
|
-
@client.execute(["curl", "server/hello"])
|
42
|
+
@client.execute(["curl", "-s", "server/hello"])
|
43
43
|
|
44
44
|
expect(@client.exit_code).to eq(0)
|
45
45
|
expect(@client.out).to eq("world\n")
|
46
|
-
expect(@client.err
|
46
|
+
expect(@client.err).to eq("")
|
47
47
|
end
|
48
48
|
|
49
49
|
after(:all) do
|