-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayload_wrapper_spec.rb
68 lines (64 loc) · 1.98 KB
/
payload_wrapper_spec.rb
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# frozen_string_literal: true
module ExcADG
describe Payload::Wrapper::Bin, uses: :payload do
before(:all) {
Broker.instance.start
}
after(:all) {
Broker.instance.teardown
}
context 'echo temp file' do
subject { Vertex.new payload: Payload::Wrapper::Bin.new(args: 'echo ${DEPS_DATAFILE}') }
it 'echoes temp file name' do
loop {
sleep 0.1
case subject&.state
when :done then break
when :failed then raise 'payload failed'
end
}
expect(subject.data.data[:exitcode]).to eq 0
expect(subject.data.data[:stdout]).to end_with "data.json\n"
end
end
context 'with dependency data' do
subject(:dep) { Vertex.new payload: Payload::Example::Echo.new(args: :pong) }
subject { Vertex.new payload: Payload::Wrapper::Bin.new(args: 'cat ${DEPS_DATAFILE}'), deps: [dep] }
it 'has deps JSON' do
loop {
sleep 0.1
case subject&.state
when :done then break
when :failed then raise 'payload failed'
end
}
expect(subject.data.data[:exitcode]).to eq 0
parsed_output = JSON.parse subject.data.data[:stdout]
expect(parsed_output.size).to eq 1
expect(parsed_output.first['data']).to eq 'pong'
expect(parsed_output.first['state']).to eq 'done'
expect(parsed_output.first['name']).to start_with 'v'
end
end
end
describe Payload::Wrapper::Ruby, uses: :payload do
before(:all) {
Broker.instance.start
}
after(:all) {
Broker.instance.teardown
}
subject { Vertex.new payload: Payload::Wrapper::Ruby.new(args: '-e "puts :pong"') }
it 'echoes pong' do
loop {
sleep 0.1
case subject&.state
when :done then break
when :failed then raise 'payload failed'
end
}
expect(subject.data.data[:exitcode]).to eq 0
expect(subject.data.data[:stdout]).to eq "pong\n"
end
end
end