fluent-plugin-typetalk 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/fluent-plugin-typetalk.gemspec +1 -1
- data/lib/fluent/plugin/out_typetalk.rb +11 -3
- data/test/plugin/test_out_typetalk.rb +14 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Zjc1OTkyYWY4NmZjZGU4MjRlYmUyNmUyMWVmYThlMjJiMGY4MGU3Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGQ4YmQ5MmVjMzJkMjc0YmVmM2UwNmYyNmQ3YTdhZTgxNDdjYzk5OA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWU3ZDdjNzI0ZGRkOGQ3YjRiMDNkNDJjMTQ3YmRjYTQzODlkY2U1NjlhZTJl
|
10
|
+
MzgxMTExYzAyZTcyMWY5ZTg5YWI1MzVjMDFmNTMxMjUwZDFiYjU0MGVhZGQy
|
11
|
+
ZGVmMGYwNmYxOWE2YmI5MGNlMjJlMTI4ZDAyNzEzNzg5Yjg0ZWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGNkNGUzY2IxNzY3ODZjYmRlNzhjMWZlMWQ0ODBlODUyMDk2OTlmMDc3ZDk4
|
14
|
+
MDUzNTE2ZmRkYmFkNjcwYWU4NTdlZDgwZjY4YWM4ODg2NDNiZGE5ZTBkYzkz
|
15
|
+
NGU4MTc2ZTcwNDRkZGYwNmZlOGQyMjdmYTgyNDE2M2NmNmIwYWM=
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-typetalk"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.6"
|
8
8
|
spec.authors = ["tksmd","umakoz"]
|
9
9
|
spec.email = ["someda@isenshi.com"]
|
10
10
|
spec.description = %q{fluent plugin to send message to typetalk}
|
@@ -115,9 +115,17 @@ module Fluent
|
|
115
115
|
res = JSON.parse(e.message) rescue {}
|
116
116
|
unless res['body'].nil?
|
117
117
|
body = JSON.parse(res['body']) rescue {}
|
118
|
-
|
119
|
-
|
120
|
-
|
118
|
+
|
119
|
+
# for auth error, the error stored in "error" property
|
120
|
+
# https://developer.nulab-inc.com/docs/typetalk/auth#client
|
121
|
+
if body.has_key?('error')
|
122
|
+
msg = body['error']
|
123
|
+
else
|
124
|
+
msg = body['errors'].map{|f|
|
125
|
+
f['field'] + ' : ' + f['message']
|
126
|
+
}.join(',')
|
127
|
+
end
|
128
|
+
|
121
129
|
end
|
122
130
|
raise TypetalkError, "failed to post, msg: #{msg}, code: #{res['status']}"
|
123
131
|
end
|
@@ -102,6 +102,20 @@ class TypetalkOutputTest < Test::Unit::TestCase
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def test_post_message_invalid_request_error
|
105
|
+
d = create_driver()
|
106
|
+
stub(d.instance.typetalk).post_message(1, 'notice : test1') {
|
107
|
+
raise Typetalk::InvalidRequest, {status:400, headers:{}, body:'{"error":"invalid_client", "error_description":""}'}.to_json
|
108
|
+
}
|
109
|
+
stub(d.instance.log).error {|name, params|
|
110
|
+
assert_equal "out_typetalk:", name
|
111
|
+
assert_equal Fluent::TypetalkError, params[:error_class]
|
112
|
+
assert_equal "failed to post, msg: invalid_client, code: 400", params[:error]
|
113
|
+
}
|
114
|
+
d.emit({'message' => 'test1'})
|
115
|
+
d.run()
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_post_message_maxlength_error
|
105
119
|
d = create_driver()
|
106
120
|
stub(d.instance.typetalk).post_message(1, 'notice : test1') {
|
107
121
|
raise Typetalk::InvalidRequest, {status:400, headers:{}, body:'{"errors":[{"field":"message", "name":"error.maxLength", "message":"Maximum length is 4,096 characters."}]}'}.to_json
|