Skip to content

Commit

Permalink
Fix tests due to NeoJSON changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Feb 23, 2024
1 parent 053ab83 commit 01c6d45
Show file tree
Hide file tree
Showing 13 changed files with 208 additions and 158 deletions.
28 changes: 15 additions & 13 deletions source/Superluminal-RESTfulAPI-Tests/CacheRepositoryTest.class.st
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
Class {
#name : #CacheRepositoryTest,
#superclass : #TestCase,
#name : 'CacheRepositoryTest',
#superclass : 'TestCase',
#instVars : [
'currentDateTime',
'repository',
'currentTimeProvider'
],
#category : #'Superluminal-RESTfulAPI-Tests-Cache'
#category : 'Superluminal-RESTfulAPI-Tests-Cache',
#package : 'Superluminal-RESTfulAPI-Tests',
#tag : 'Cache'
}

{ #category : #testing }
{ #category : 'testing' }
CacheRepositoryTest class >> isAbstract [

^ self name = #CacheRepositoryTest
]

{ #category : #private }
{ #category : 'private' }
CacheRepositoryTest >> resourceFor: answer expiringIn: aDuration [

| headers response |
Expand All @@ -30,7 +32,7 @@ CacheRepositoryTest >> resourceFor: answer expiringIn: aDuration [
^ ExpiringResource for: answer controlledBy: response
]

{ #category : #running }
{ #category : 'running' }
CacheRepositoryTest >> setUp [

super setUp.
Expand All @@ -39,13 +41,13 @@ CacheRepositoryTest >> setUp [
self setUpRepository
]

{ #category : #running }
{ #category : 'running' }
CacheRepositoryTest >> setUpRepository [

self subclassResponsibility
]

{ #category : #tests }
{ #category : 'tests' }
CacheRepositoryTest >> testExpiring [

| answer resource |
Expand All @@ -58,7 +60,7 @@ CacheRepositoryTest >> testExpiring [
self should: [ repository get: 'key' ] raise: KeyNotFound withMessageText: '''key'' not found'
]

{ #category : #tests }
{ #category : 'tests' }
CacheRepositoryTest >> testGetKeyIfAbsent [

self
Expand All @@ -67,7 +69,7 @@ CacheRepositoryTest >> testGetKeyIfAbsent [
withMessageText: '''absent_key'' not found'
]

{ #category : #tests }
{ #category : 'tests' }
CacheRepositoryTest >> testRemove [

| answer |
Expand All @@ -79,13 +81,13 @@ CacheRepositoryTest >> testRemove [
self should: [ repository get: 'key' ] raise: KeyNotFound withMessageText: '''key'' not found'
]

{ #category : #tests }
{ #category : 'tests' }
CacheRepositoryTest >> testRemoveAbsentKey [

self shouldnt: [ repository remove: 'absent_key' ] raise: KeyNotFound
]

{ #category : #tests }
{ #category : 'tests' }
CacheRepositoryTest >> testStoreAt [

| answer |
Expand All @@ -95,7 +97,7 @@ CacheRepositoryTest >> testStoreAt [
self assert: ( repository get: 'key' ) contents equals: answer
]

{ #category : #running }
{ #category : 'running' }
CacheRepositoryTest >> waitFor: aDuration [

self subclassResponsibility
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
Class {
#name : #DistributedMemoryBasedExpiringCacheTest,
#superclass : #ExpiringCacheTest,
#category : #'Superluminal-RESTfulAPI-Tests-Cache'
#name : 'DistributedMemoryBasedExpiringCacheTest',
#superclass : 'ExpiringCacheTest',
#category : 'Superluminal-RESTfulAPI-Tests-Cache',
#package : 'Superluminal-RESTfulAPI-Tests',
#tag : 'Cache'
}

{ #category : #running }
{ #category : 'running' }
DistributedMemoryBasedExpiringCacheTest >> setUpExpiringCache [

| memcached |
memcached := MDCacheClient onServers: {'127.0.0.1:11211'}.
cache := ExpiringCache persistingTo: (DistributedMemoryCacheRepository using: currentTimeProvider persistingTo: memcached).
]

{ #category : #private }
{ #category : 'private' }
DistributedMemoryBasedExpiringCacheTest >> waitFor: aDuration [

currentDateTime := currentDateTime + aDuration.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
Class {
#name : #DistributedMemoryCacheRepositoryTest,
#superclass : #CacheRepositoryTest,
#name : 'DistributedMemoryCacheRepositoryTest',
#superclass : 'CacheRepositoryTest',
#instVars : [
'memcached'
],
#category : #'Superluminal-RESTfulAPI-Tests-Cache'
#category : 'Superluminal-RESTfulAPI-Tests-Cache',
#package : 'Superluminal-RESTfulAPI-Tests',
#tag : 'Cache'
}

{ #category : #running }
{ #category : 'running' }
DistributedMemoryCacheRepositoryTest >> setUpRepository [

repository := DistributedMemoryCacheRepository
using: currentTimeProvider
persistingTo: ( MDCacheClient onServers: {'127.0.0.1:11211'} )
]

{ #category : #private }
{ #category : 'private' }
DistributedMemoryCacheRepositoryTest >> waitFor: aDuration [

currentDateTime := currentDateTime + aDuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
An ExpiringCacheKeyBuilderTest is a test class for testing the behavior of ExpiringCacheKeyBuilder
"
Class {
#name : #ExpiringCacheKeyBuilderTest,
#superclass : #TestCase,
#category : #'Superluminal-RESTfulAPI-Tests-Cache'
#name : 'ExpiringCacheKeyBuilderTest',
#superclass : 'TestCase',
#category : 'Superluminal-RESTfulAPI-Tests-Cache',
#package : 'Superluminal-RESTfulAPI-Tests',
#tag : 'Cache'
}

{ #category : #test }
{ #category : 'test' }
ExpiringCacheKeyBuilderTest >> testEntity [

| httpRequest key |
Expand All @@ -20,7 +22,7 @@ ExpiringCacheKeyBuilderTest >> testEntity [
self assert: key equals: 'http://google.com/'
]

{ #category : #test }
{ #category : 'test' }
ExpiringCacheKeyBuilderTest >> testFormAtAdd [

| httpRequest key |
Expand All @@ -33,7 +35,7 @@ ExpiringCacheKeyBuilderTest >> testFormAtAdd [
self assert: key equals: 'http://google.com/|form-query[ba-st]'
]

{ #category : #test }
{ #category : 'test' }
ExpiringCacheKeyBuilderTest >> testHeaderAtPut [

| httpRequest key |
Expand Down
26 changes: 14 additions & 12 deletions source/Superluminal-RESTfulAPI-Tests/ExpiringCacheTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@
An ExpiringCacheTest is a test class for testing the behavior of ExpiringCache
"
Class {
#name : #ExpiringCacheTest,
#superclass : #TestCase,
#name : 'ExpiringCacheTest',
#superclass : 'TestCase',
#instVars : [
'currentDateTime',
'cache',
'location',
'currentTimeProvider'
],
#category : #'Superluminal-RESTfulAPI-Tests-Cache'
#category : 'Superluminal-RESTfulAPI-Tests-Cache',
#package : 'Superluminal-RESTfulAPI-Tests',
#tag : 'Cache'
}

{ #category : #testing }
{ #category : 'testing' }
ExpiringCacheTest class >> isAbstract [

^ self name = #ExpiringCacheTest
]

{ #category : #private }
{ #category : 'private' }
ExpiringCacheTest >> in: aResource obtain: answer cachedFor: aDuration [

^ cache
Expand All @@ -28,13 +30,13 @@ ExpiringCacheTest >> in: aResource obtain: answer cachedFor: aDuration [
do: [ :resource | 'Obtained <1s>' expandMacrosWith: resource ]
]

{ #category : #private }
{ #category : 'private' }
ExpiringCacheTest >> obtain: answer cachedFor: aDuration [

^ self in: location obtain: answer cachedFor: aDuration
]

{ #category : #private }
{ #category : 'private' }
ExpiringCacheTest >> resourceFor: answer expiringIn: aDuration [

| response |
Expand All @@ -45,7 +47,7 @@ ExpiringCacheTest >> resourceFor: answer expiringIn: aDuration [
^ ExpiringResource for: answer controlledBy: response
]

{ #category : #running }
{ #category : 'running' }
ExpiringCacheTest >> setUp [

super setUp.
Expand All @@ -55,13 +57,13 @@ ExpiringCacheTest >> setUp [
self setUpExpiringCache
]

{ #category : #running }
{ #category : 'running' }
ExpiringCacheTest >> setUpExpiringCache [

self subclassResponsibility
]

{ #category : #tests }
{ #category : 'tests' }
ExpiringCacheTest >> testCachedAnswerIsReturnedBeforeExpiration [

| answer |
Expand All @@ -76,7 +78,7 @@ ExpiringCacheTest >> testCachedAnswerIsReturnedBeforeExpiration [
self assert: ( self obtain: answer cachedFor: 2 seconds ) equals: 'Obtained an updated answer'
]

{ #category : #tests }
{ #category : 'tests' }
ExpiringCacheTest >> testClearResourceAt [

| answer |
Expand All @@ -89,7 +91,7 @@ ExpiringCacheTest >> testClearResourceAt [
self assert: ( self obtain: answer cachedFor: 2 seconds ) equals: 'Obtained an updated answer'
]

{ #category : #private }
{ #category : 'private' }
ExpiringCacheTest >> waitFor: aDuration [

self subclassResponsibility
Expand Down
Loading

0 comments on commit 01c6d45

Please sign in to comment.