@@ -111,8 +111,8 @@ describe('core', function() {
111111
112112 describe ( '#problems' , function ( ) {
113113 var PROBLEMS = [
114- { id : 0 , name : 'name0' , slug : 'slug0' , starred : false } ,
115- { id : 1 , name : 'name1' , slug : 'slug1' , starred : true }
114+ { id : 0 , name : 'name0' , slug : 'slug0' , starred : false , category : 'algorithms' } ,
115+ { id : 1 , name : 'name1' , slug : 'slug1' , starred : true , category : 'algorithms' }
116116 ] ;
117117 var RESULTS = [
118118 { name : 'result0' } ,
@@ -121,7 +121,7 @@ describe('core', function() {
121121
122122 describe ( '#getProblems' , function ( ) {
123123 it ( 'should getProblems w/ cache ok' , function ( done ) {
124- cache . set ( 'all ' , PROBLEMS ) ;
124+ cache . set ( 'problems ' , PROBLEMS ) ;
125125
126126 core . getProblems ( function ( e , problems ) {
127127 assert . equal ( e , null ) ;
@@ -131,7 +131,7 @@ describe('core', function() {
131131 } ) ;
132132
133133 it ( 'should getProblems w/o cache ok' , function ( done ) {
134- cache . del ( 'all ' ) ;
134+ cache . del ( 'problems ' ) ;
135135
136136 client . getProblems = function ( category , user , cb ) {
137137 return cb ( null , PROBLEMS ) ;
@@ -145,7 +145,7 @@ describe('core', function() {
145145 } ) ;
146146
147147 it ( 'should getProblems w/o cache fail if client error' , function ( done ) {
148- cache . del ( 'all ' ) ;
148+ cache . del ( 'problems ' ) ;
149149
150150 client . getProblems = function ( category , user , cb ) {
151151 return cb ( 'client getProblems error' ) ;
@@ -160,8 +160,8 @@ describe('core', function() {
160160
161161 describe ( '#getProblem' , function ( ) {
162162 it ( 'should getProblem by id w/ cache ok' , function ( done ) {
163- cache . set ( 'all ' , PROBLEMS ) ;
164- cache . set ( 'slug0' , PROBLEMS [ 0 ] ) ;
163+ cache . set ( 'problems ' , PROBLEMS ) ;
164+ cache . set ( '0. slug0.algorithms ' , PROBLEMS [ 0 ] ) ;
165165
166166 core . getProblem ( 0 , function ( e , problem ) {
167167 assert . equal ( e , null ) ;
@@ -171,8 +171,8 @@ describe('core', function() {
171171 } ) ;
172172
173173 it ( 'should getProblem by name w/ cache ok' , function ( done ) {
174- cache . set ( 'all ' , PROBLEMS ) ;
175- cache . set ( 'slug0' , PROBLEMS [ 0 ] ) ;
174+ cache . set ( 'problems ' , PROBLEMS ) ;
175+ cache . set ( '0. slug0.algorithms ' , PROBLEMS [ 0 ] ) ;
176176
177177 core . getProblem ( 'name0' , function ( e , problem ) {
178178 assert . equal ( e , null ) ;
@@ -182,8 +182,8 @@ describe('core', function() {
182182 } ) ;
183183
184184 it ( 'should getProblem by key w/ cache ok' , function ( done ) {
185- cache . set ( 'all ' , PROBLEMS ) ;
186- cache . set ( 'slug0' , PROBLEMS [ 0 ] ) ;
185+ cache . set ( 'problems ' , PROBLEMS ) ;
186+ cache . set ( '0. slug0.algorithms ' , PROBLEMS [ 0 ] ) ;
187187
188188 core . getProblem ( 'slug0' , function ( e , problem ) {
189189 assert . equal ( e , null ) ;
@@ -193,8 +193,8 @@ describe('core', function() {
193193 } ) ;
194194
195195 it ( 'should getProblem by id w/o cache ok' , function ( done ) {
196- cache . set ( 'all ' , PROBLEMS ) ;
197- cache . del ( 'slug0' ) ;
196+ cache . set ( 'problems ' , PROBLEMS ) ;
197+ cache . del ( '0. slug0.algorithms ' ) ;
198198
199199 client . getProblem = function ( user , problem , cb ) {
200200 return cb ( null , problem ) ;
@@ -208,7 +208,7 @@ describe('core', function() {
208208 } ) ;
209209
210210 it ( 'should getProblem error if not found' , function ( done ) {
211- cache . set ( 'all ' , PROBLEMS ) ;
211+ cache . set ( 'problems ' , PROBLEMS ) ;
212212
213213 core . getProblem ( 3 , function ( e , problem ) {
214214 assert . equal ( e , 'Problem not found!' ) ;
@@ -217,8 +217,8 @@ describe('core', function() {
217217 } ) ;
218218
219219 it ( 'should getProblem fail if client error' , function ( done ) {
220- cache . set ( 'all ' , PROBLEMS ) ;
221- cache . del ( 'slug0' ) ;
220+ cache . set ( 'problems ' , PROBLEMS ) ;
221+ cache . del ( '0. slug0.algorithms ' ) ;
222222
223223 client . getProblem = function ( user , problem , cb ) {
224224 return cb ( 'client getProblem error' ) ;
@@ -231,7 +231,7 @@ describe('core', function() {
231231 } ) ;
232232
233233 it ( 'should getProblem fail if getProblems error' , function ( done ) {
234- cache . del ( 'all ' ) ;
234+ cache . del ( 'problems ' ) ;
235235 client . getProblems = function ( category , user , cb ) {
236236 return cb ( 'getProblems error' ) ;
237237 } ;
@@ -245,8 +245,8 @@ describe('core', function() {
245245
246246 describe ( '#updateProblem' , function ( ) {
247247 it ( 'should updateProblem ok' , function ( done ) {
248- cache . set ( 'all ' , PROBLEMS ) ;
249- cache . del ( 'slug0' ) ;
248+ cache . set ( 'problems ' , PROBLEMS ) ;
249+ cache . del ( '0. slug0.algorithms ' ) ;
250250
251251 var kv = { value : 'value00' } ;
252252 var ret = core . updateProblem ( PROBLEMS [ 0 ] , kv ) ;
@@ -255,19 +255,19 @@ describe('core', function() {
255255 core . getProblem ( 0 , function ( e , problem ) {
256256 assert . equal ( e , null ) ;
257257 assert . deepEqual ( problem ,
258- { id : 0 , name : 'name0' , slug : 'slug0' , value : 'value00' , starred : false } ) ;
258+ { id : 0 , name : 'name0' , slug : 'slug0' , value : 'value00' , starred : false , category : 'algorithms' } ) ;
259259 done ( ) ;
260260 } ) ;
261261 } ) ;
262262
263263 it ( 'should updateProblem fail if no problems found' , function ( ) {
264- cache . del ( 'all ' ) ;
264+ cache . del ( 'problems ' ) ;
265265 var ret = core . updateProblem ( PROBLEMS [ 0 ] , { } ) ;
266266 assert . equal ( ret , false ) ;
267267 } ) ;
268268
269269 it ( 'should updateProblem fail if unknown problem' , function ( ) {
270- cache . set ( 'all ' , [ PROBLEMS [ 1 ] ] ) ;
270+ cache . set ( 'problems ' , [ PROBLEMS [ 1 ] ] ) ;
271271 var ret = core . updateProblem ( PROBLEMS [ 0 ] , { } ) ;
272272 assert . equal ( ret , false ) ;
273273 } ) ;
0 commit comments