Skip to content

Commit

Permalink
Merge pull request #61 from tinchodias/update_tests
Browse files Browse the repository at this point in the history
Update tests
  • Loading branch information
estebanlm committed Sep 21, 2016
2 parents 7f90c15 + e18b1c6 commit fbf00dd
Show file tree
Hide file tree
Showing 42 changed files with 91 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ testCount
| pilot |
pilot := VOTestPilot new name: 'Esteban'.
self assert: (self repository count: VOTestPilot) equals: 0.

self repository save: pilot.
self waitForWriteOperation.

self assert: (self repository count: VOTestPilot) equals: 1

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ testIsLazy
lazyPet: (VOTestDog new name: 'LazyDoggie').
self repository save: pilot.
self repository flushCache.

self waitForWriteOperation.

retrievedPilot := self repository selectOne: VOTestPilot where: [ :each | (each at: 'name') = 'Esteban' ].
"self assert: (retrievedPilot instVarNamed: 'lazyPet') class equals: VOLazyProxy."
self assert: retrievedPilot lazyPet name equals: 'LazyDoggie'.
self assert: retrievedPilot lazyPet name equals: 'LazyDoggie'.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests
testIsLazyOnToManyRelations
| pilot pilots retrievedPilot |
| pilot retrievedPilot |
pilot := VOTestPilot new
name: 'Esteban';
pastPets: (Array with: (VOTestDog new name: 'Doggie') with: (VOTestDog new name: 'Kittie')).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ testIsNew
self assert: (self repository isNew: pilot pet).

self repository save: pilot.

self waitForWriteOperation.

self deny: (self repository isNew: pilot).
self deny: (self repository isNew: pilot pet).
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ testSave
name: 'Esteban';
pet: (VOTestDog new name: 'Doggie').
self repository save: pilot.

self waitForWriteOperation.

pilots := self repository selectAll: VOTestPilot.
self assert: pilots size equals: 1.
self assert: pilots first name equals: 'Esteban'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ testSaveCircular
name: 'Miau';
yourself);
yourself.


self
assert: (self repository count: VOTestOwner)
equals: 0.

self repository save: owner.
self waitForWriteOperation.

self
assert: (self repository count: VOTestOwner)
equals: 1.
self
assert: (self repository selectOne: VOTestOwner where: [ :each | (each at: 'name') = 'test owner' ])
equals: owner.

self
assert: (self repository selectAll: VOTestPet) size
equals: 2.


assert: (self repository count: VOTestPet)
equals: 2.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
tests
testSaveWithClasses
self repository save: (VOTestPilot new currency: VOTestEuro).
self waitForWriteOperation.

self assert: (self repository selectAll: VOTestPilot) first currency equals: VOTestEuro.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ testSaveWithSubclasses
self repository save: (VOTestDog new name: 'Rantanplan').
self repository save: (VOTestDog new name: 'Medor').
self repository save: (VOTestCat new name: 'Pizza').
self waitForWriteOperation.

self assert: (self repository selectAll: VOTestPet) size equals: 3.
self assert: (self repository selectAll: VOTestDog) size equals: 2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ testSaveWithSubclassesAndRelations
mozart := VOTestPilot new
name: 'Mozart';
pet: (VOTestDog new name: 'Medor').

self repository save: mozart.
self waitForWriteOperation.

"Make sure we got a dog back"
self assert: (self repository selectAll: VOTestPilot) first pet bark equals: 'Wouf!'.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ testSelectManyWithAllKeyword
self repository save: pilot2.
self repository save: pilot3.
self repository flushCache.
self waitForWriteOperation.

mongoQuery := Dictionary new
at: 'keywords' put: (Dictionary new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ testSelectManyWithLimitAndOffset
save: (VOTestPilot new name: 'Markus');
yourself.
self repository flushCache.
self waitForWriteOperation.

firstBatch := self repository selectMany: VOTestPilot where: Dictionary new limit: 2.
secondBatch := self repository selectMany: VOTestPilot where: Dictionary new limit: 2 offset: 2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ tests
testSelectOneWithSubclass
| retrieved |
self repository save: (VOTestCat new name: 'Pizza').
self waitForWriteOperation.

retrieved := self repository selectOne: VOTestPet where: [ :each | (each at: 'name') = 'Pizza' ].
self deny: retrieved isNil.
self assert: retrieved class equals: VOTestCat. "object is still in cache with the good class."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ testUpdate
name: 'Esteban';
pet: (VOTestDog new name: 'Doggie').
self repository save: pilot.
self waitForWriteOperation.

id := self repository idOf: pilot.

pilot name: 'Another Pilot'.
self repository save: pilot.
self waitForWriteOperation.

pilots := self repository selectAll: VOTestPilot.
self assert: pilots size equals: 1.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
running
waitForWriteOperation
"Write operations can require some time to be applied by backend, and this template method can be overriden by subclasses to do something."

"Do nothing by default"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"testCount" : "FrancoisStephany 9/6/2012 15:30",
"testCountWhere" : "EstebanLorenzano 6/14/2016 14:42",
"testIsLazy" : "EstebanLorenzano 6/14/2016 13:05",
"testIsLazyOnToManyRelations" : "EstebanLorenzano 6/14/2016 15:02",
"testIsLazyOnToManyRelations" : "MartinDias 9/19/2016 01:12",
"testIsNew" : "FrancoisStephany 11/14/2012 20:26",
"testSave" : "EstebanLorenzano 6/13/2016 18:27",
"testSaveCircular" : "EstebanLorenzano 6/14/2016 13:41",
Expand All @@ -18,4 +18,5 @@
"testSelectOneWithSubclass" : "EstebanLorenzano 6/14/2016 14:43",
"testUpdate" : "EstebanLorenzano 2/11/2016 19:01",
"testVersionAt" : "MartinDias 4/15/2016 01:23",
"testVersionGenerator" : "EstebanLorenzano 6/15/2016 14:18" } }
"testVersionGenerator" : "EstebanLorenzano 6/15/2016 14:18",
"waitForWriteOperation" : "MartinDias 9/3/2016 15:57" } }
4 changes: 2 additions & 2 deletions mc/Voyage-Model-Tests.package/monticello.meta/version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(name 'Voyage-Model-Tests-MartinDias.5' message 'Remove #testSelectAllJustAfterRemove, it does not show anything relevant, we know there are concurrency problems when no "write concerns" or equivalent is used to check that mongodb database finished a write operation.' id 'c31ddca0-5ae3-41a3-a97a-e5c74da0b275' date '5 September 2016' time '4:17:40.782815 pm' author 'MartinDias' ancestors ((name 'Voyage-Model-Tests-EstebanLorenzano.4' message 'using new descriptions for test' id 'e102d37d-d7d3-4845-917e-6bcd0d914010' date '3 August 2016' time '6:27:20.650685 pm' author 'EstebanLorenzano' ancestors ((name 'Voyage-Model-Tests-EstebanLorenzano.3' message 'model for test moved to generic package
' id 'aea8069f-9aa9-5ef7-bc47-36932e3bf144' date '3 August 2016' time '6:19:41 pm' author 'EstebanLorenzano' ancestors () stepChildren ())) stepChildren ())) stepChildren ())
(name 'Voyage-Model-Tests-MartinDias.6' message 'Adding VORepositoryTest>>waitForWriteOperation. Purpose: Write operations can require some time to be applied by backend, and this template method can be overriden by subclasses to do something. Do nothing by default.' id '66f21a79-5079-46ff-9625-d8726363e4cb' date '19 September 2016' time '9:22:27.214928 pm' author 'MartinDias' ancestors ((name 'Voyage-Model-Tests-MartinDias.5' message 'Remove #testSelectAllJustAfterRemove, it does not show anything relevant, we know there are concurrency problems when no "write concerns" or equivalent is used to check that mongodb database finished a write operation.' id 'c31ddca0-5ae3-41a3-a97a-e5c74da0b275' date '5 September 2016' time '4:17:40.782815 pm' author 'MartinDias' ancestors ((name 'Voyage-Model-Tests-EstebanLorenzano.4' message 'using new descriptions for test' id 'e102d37d-d7d3-4845-917e-6bcd0d914010' date '3 August 2016' time '6:27:20.650685 pm' author 'EstebanLorenzano' ancestors ((name 'Voyage-Model-Tests-EstebanLorenzano.3' message 'model for test moved to generic package
' id 'aea8069f-9aa9-5ef7-bc47-36932e3bf144' date '3 August 2016' time '6:19:41 pm' author 'EstebanLorenzano' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
running
setUp
super setUp.

setUpRepository
"Note that `mongo B` is a secondary member, then the repository must figure out this fact, and discover the primary member in the replica set."
repository := MongoReplicationTestResources newRepositoryOnB.

repository := MongoReplicationTestResources newRepositoryOnB
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
"class" : {
},
"instance" : {
"repository" : "MartinDias 6/15/2016 10:18",
"setUp" : "MartinDias 6/17/2016 15:35" } }
"setUpRepository" : "MartinDias 9/19/2016 20:04" } }
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"commentStamp" : "MartinDias 6/17/2016 15:44",
"instvars" : [
"repository" ],
],
"name" : "VOMongoReplicationDiscoverPrimaryScenarioTest",
"pools" : [
],
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
running
setUpRepository
"Simplest scenario: Specify primary member in the replica set."

repository := MongoReplicationTestResources newRepositoryOnA
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
"class" : {
},
"instance" : {
"repository" : "MartinDias 5/11/2016 19:35",
"setUp" : "MartinDias 6/17/2016 15:49" } }
"setUpRepository" : "MartinDias 9/19/2016 20:04" } }
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"commentStamp" : "MartinDias 6/17/2016 15:45",
"instvars" : [
"repository" ],
],
"name" : "VOMongoReplicationSimplestScenarioTest",
"pools" : [
],
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
accessing
repository
^ VOMongoTestResource current repository
^ repository
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
running
setUp
super setUp.
self setUpRepository.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
running
setUpRepository
"Hook: subclasses can override with special ways of building the test repository"

repository := VOMongoRepository
host: self class mongoHost
database: 'Voyage-Tests'.
repository debug: true.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
running
tearDown
"Reset the DB after each test"
"self repository dropDatabase --> this works but it's slow and... leaks open Sockets!"
"self repository dropDatabase"

self repository
removeAll: VOTestOwner;
removeAll: VOTestPet;
removeAll: VOTestPilot;
flush.
super tearDown.

(VOTestObject allSubclasses
collect: [ :each | each persistentClass ] as: Set)
do: [ :each | repository removeAll: each ].

Smalltalk garbageCollect.

800 milliseconds asDelay wait. "Wait to reduce the probability of a concurrency conflict"
self waitForWriteOperation.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
running
waitForWriteOperation
"Write operations can be performed in a fire-and-forget mode, and it's convenient to wait a bit to ensure mongodb performed it before asserting on the results."

50 milliSeconds wait
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"class" : {
"resources" : "FrancoisStephany 8/8/2012 15:03" },
"mongoHost" : "MartinDias 9/19/2016 19:33",
"mongoHost:" : "MartinDias 9/19/2016 19:34" },
"instance" : {
"repository" : "EstebanLorenzano 4/21/2015 16:43",
"tearDown" : "MartinDias 5/16/2016 00:40" } }
"repository" : "MartinDias 9/19/2016 19:26",
"setUp" : "MartinDias 9/19/2016 20:05",
"setUpRepository" : "MartinDias 9/19/2016 20:06",
"tearDown" : "MartinDias 9/19/2016 19:32",
"waitForWriteOperation" : "MartinDias 9/21/2016 16:04" } }
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"classinstvars" : [
],
"classvars" : [
],
"MongoHost" ],
"commentStamp" : "EstebanLorenzano 8/3/2016 17:43",
"instvars" : [
],
"repository" ],
"name" : "VOMongoTest",
"pools" : [
],
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion mc/Voyage-Mongo-Tests.package/monticello.meta/version

Large diffs are not rendered by default.

0 comments on commit fbf00dd

Please sign in to comment.