Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
It is possible to create hundreds of temporary articles in the server using TM
  • Loading branch information
michaelhidalgo committed Apr 15, 2015
1 parent 37ee50e commit 1b22ee8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/api/base-classes/Swagger-GraphDB.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class Swagger_GraphDB extends Swagger_Common
super(options)

close_Import_Service_and_Send: (importService, res, data, key)=>
@.save_To_Cache(key,data)
if (data?.article_Id)
@.save_To_Cache(key,data)
importService.graph.closeDb =>
res.send data?.json_pretty()

Expand Down
42 changes: 36 additions & 6 deletions test/api/base-classes/Swagger-GraphDB.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ describe '| api | base-classes | Swagger-GraphDB.test |', ->
@.swaggerService.assert_Is options.swaggerService

it 'close_Import_Service_and_Send', (done)->
temp_Data = 'data_'.add_5_Letters()
temp_Data = {article_Id:'data_'.add_5_Letters()}
temp_Key = 'key_'.add_5_Letters()
importService =
graph:
closeDb: (callback)=>
callback()
res =
send: (data)=>
data.assert_Is (temp_Data.json_Str())
tmp_Cache.get(temp_Key).assert_Is temp_Data
data.json_Parse().json_Str().assert_Is (temp_Data.json_Str())
tmp_Cache.get(temp_Key).json_Parse().json_Str().assert_Is (temp_Data.json_Str())
done()

options =
Expand Down Expand Up @@ -104,13 +104,43 @@ describe '| api | base-classes | Swagger-GraphDB.test | open_Import_Service', ->

it 'sending data not in cache', (done)->

temp_Data = 'data_'.add_5_Letters()
temp_Data = {article_Id:'data_'.add_5_Letters()}
temp_Key = 'key_'.add_5_Letters()

res =
send: (data)=>
data .assert_Is temp_Data.json_Str()
tmp_Cache.get(temp_Key).assert_Is temp_Data
data.json_Parse().json_Str().assert_Is(temp_Data.json_Str())
tmp_Cache.get(temp_Key).json_Parse().json_Str().assert_Is (temp_Data.json_Str())
done()

swagger_DB.open_Import_Service res, temp_Key, (_importService)->
importService = _importService
swagger_DB.close_Import_Service_and_Send importService, res, temp_Data, temp_Key

it 'Invalid articles should not be created in cache', (done)->

temp_Data = 'data_'.add_5_Letters()
temp_Key = 'key_'.add_Random_Letters (1000);

res =
send: (data)=>
data.json_Parse().json_Str().assert_Is(temp_Data.json_Str())
tmp_Cache.has_Key(temp_Key).assert_Is_False()
done()

swagger_DB.open_Import_Service res, temp_Key, (_importService)->
importService = _importService
swagger_DB.close_Import_Service_and_Send importService, res, temp_Data, temp_Key

it 'Invalid articles (NULL) should not be created in cache', (done)->

temp_Data = undefined
temp_Key = 'key_'.add_Random_Letters (1000);

res =
send: (data)=>
data?.assert_Is_Undefined()
tmp_Cache.has_Key(temp_Key).assert_Is_False()
done()

swagger_DB.open_Import_Service res, temp_Key, (_importService)->
Expand Down

0 comments on commit 1b22ee8

Please sign in to comment.