Class: Fluent::Test::InputTestDriver
Instance Attribute Summary collapse
Attributes inherited from TestDriver
#config, #instance
Instance Method Summary
collapse
Methods inherited from TestDriver
#configure
Constructor Details
Returns a new instance of InputTestDriver.
23
24
25
26
27
|
# File 'lib/fluent/test/input_test.rb', line 23
def initialize(klass, &block)
super(klass, &block)
@emit_streams = []
@expects = nil
end
|
Instance Attribute Details
#emit_streams ⇒ Object
Returns the value of attribute emit_streams.
38
39
40
|
# File 'lib/fluent/test/input_test.rb', line 38
def emit_streams
@emit_streams
end
|
Instance Method Details
#emits ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'lib/fluent/test/input_test.rb', line 40
def emits
all = []
@emit_streams.each {|tag,events|
events.each {|time,record|
all << [tag, time, record]
}
}
all
end
|
#events ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/fluent/test/input_test.rb', line 50
def events
all = []
@emit_streams.each {|tag,events|
all.concat events
}
all
end
|
#expect_emit(tag, time, record) ⇒ Object
29
30
31
32
|
# File 'lib/fluent/test/input_test.rb', line 29
def expect_emit(tag, time, record)
(@expects ||= []) << [tag, time, record]
self
end
|
#expected_emits ⇒ Object
34
35
36
|
# File 'lib/fluent/test/input_test.rb', line 34
def expected_emits
@expects ||= []
end
|
#records ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/fluent/test/input_test.rb', line 58
def records
all = []
@emit_streams.each {|tag,events|
events.each {|time,record|
all << record
}
}
all
end
|
#run(&block) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/fluent/test/input_test.rb', line 68
def run(&block)
m = method(:emit_stream)
super {
Engine.define_singleton_method(:emit_stream) {|tag,es|
m.call(tag, es)
}
block.call if block
if @expects
i = 0
@emit_streams.each {|tag,events|
events.each {|time,record|
assert_equal(@expects[i], [tag, time, record])
i += 1
}
}
assert_equal @expects.length, i
end
}
self
end
|