26
26
static NSTimeInterval kDatafileDownloadInteval = 5 ; // in seconds
27
27
static NSString *const kLastModifiedDate = @" Mon, 28 Nov 2016 06:10:59 GMT" ;
28
28
static NSData *kDatafileData ;
29
+ static NSDictionary *const kCDNResponseHeaders =@{@" Content-Type" :@" application/json" ,
30
+ @" Last-Modified" :kLastModifiedDate };
29
31
30
32
@interface OPTLYDatafileManager (test)
31
33
@property (nonatomic , strong ) NSTimer *datafileDownloadTimer;
@@ -148,6 +150,8 @@ - (void)testDatafileManagerDownloadDatafileSavesDatafile {
148
150
149
151
// make sure we were able to save the datafile
150
152
[self waitForExpectationsWithTimeout: 2 handler: nil ];
153
+
154
+ // clean up stub
151
155
[OHHTTPStubs removeStub: stub];
152
156
}
153
157
@@ -242,8 +246,7 @@ - (void)test304Response
242
246
} withStubResponse: ^OHHTTPStubsResponse *(NSURLRequest *request) {
243
247
return [OHHTTPStubsResponse responseWithData: kDatafileData
244
248
statusCode: 200
245
- headers: @{@" Content-Type" :@" application/json" ,
246
- @" Last-Modified" :kLastModifiedDate }];
249
+ headers: kCDNResponseHeaders ];
247
250
}];
248
251
}
249
252
@@ -258,14 +261,12 @@ - (void)test304Response
258
261
if ([request.allHTTPHeaderFields objectForKey: @" If-Modified-Since" ] != nil ) {
259
262
return [OHHTTPStubsResponse responseWithData: nil
260
263
statusCode: 304
261
- headers: @{@" Content-Type" :@" application/json" ,
262
- @" Last-Modified" :kLastModifiedDate }];
264
+ headers: kCDNResponseHeaders ];
263
265
}
264
266
else {
265
267
return [OHHTTPStubsResponse responseWithData: kDatafileData
266
268
statusCode: 200
267
- headers: @{@" Content-Type" :@" application/json" ,
268
- @" Last-Modified" :kLastModifiedDate }];
269
+ headers: kCDNResponseHeaders ];
269
270
270
271
}
271
272
}];
@@ -281,8 +282,7 @@ - (void)test304Response
281
282
} withStubResponse: ^OHHTTPStubsResponse *(NSURLRequest *request) {
282
283
return [OHHTTPStubsResponse responseWithData: nil
283
284
statusCode: 400
284
- headers: @{@" Content-Type" :@" application/json" ,
285
- @" Last-Modified" :kLastModifiedDate }];
285
+ headers: kCDNResponseHeaders ];
286
286
}];
287
287
}
288
288
0 commit comments