@@ -66,6 +66,19 @@ describe.each([
66
66
expect ( mockHttp . isDone ( ) ) ;
67
67
} ) ;
68
68
} ) ;
69
+
70
+ it ( 'should throw an error if the push failed' , ( ) => {
71
+ nock ( 'http://192.168.99.100:9091' )
72
+ . post ( '/metrics/job/testJob/key/value' , body )
73
+ . reply ( 400 ) ;
74
+
75
+ return expect (
76
+ instance . pushAdd ( {
77
+ jobName : 'testJob' ,
78
+ groupings : { key : 'value' } ,
79
+ } ) ,
80
+ ) . rejects . toThrow ( 'push failed with status 400' ) ;
81
+ } ) ;
69
82
} ) ;
70
83
71
84
describe ( 'push' , ( ) => {
@@ -88,6 +101,19 @@ describe.each([
88
101
expect ( mockHttp . isDone ( ) ) ;
89
102
} ) ;
90
103
} ) ;
104
+
105
+ it ( 'should throw an error if the push failed' , ( ) => {
106
+ nock ( 'http://192.168.99.100:9091' )
107
+ . put ( '/metrics/job/testJob/key/value' , body )
108
+ . reply ( 400 ) ;
109
+
110
+ return expect (
111
+ instance . push ( {
112
+ jobName : 'testJob' ,
113
+ groupings : { key : 'value' } ,
114
+ } ) ,
115
+ ) . rejects . toThrow ( 'push failed with status 400' ) ;
116
+ } ) ;
91
117
} ) ;
92
118
93
119
describe ( 'delete' , ( ) => {
@@ -100,6 +126,16 @@ describe.each([
100
126
expect ( mockHttp . isDone ( ) ) ;
101
127
} ) ;
102
128
} ) ;
129
+
130
+ it ( 'should throw an error if the push failed' , ( ) => {
131
+ nock ( 'http://192.168.99.100:9091' )
132
+ . delete ( '/metrics/job/testJob' )
133
+ . reply ( 400 ) ;
134
+
135
+ return expect ( instance . delete ( { jobName : 'testJob' } ) ) . rejects . toThrow (
136
+ 'push failed with status 400' ,
137
+ ) ;
138
+ } ) ;
103
139
} ) ;
104
140
105
141
describe ( 'when using basic authentication' , ( ) => {
0 commit comments