Skip to content

Commit

Permalink
adds more MongoAPI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianconcept committed Mar 1, 2024
1 parent 36f009e commit 6c2ae8d
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions src/Mapless-Mongo-Tests/MaplessMongoAPITest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,83 @@ MaplessMongoAPITest >> testGetMongoInfo [
self assert: api admin isMaster class equals: MongoIsMaster.
api close
]

{ #category : #tests }
MaplessMongoAPITest >> testInitializeIsPrimary [

| api result |
api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'.
api open.

self shouldnt: [ result := api isPrimary ] raise: Error.
self deny: result.
api close
]

{ #category : #tests }
MaplessMongoAPITest >> testIsPrimary [

| api result |
api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'.
api open.

self
shouldnt: [ result := api admin isMaster isPrimary ]
raise: Error.
self deny: result.
api close
]

{ #category : #tests }
MaplessMongoAPITest >> testIsReadOnly [

| api |
api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'.
api open.

self shouldnt: [ api isPrimary ] raise: Error.
self assert: api isReadOnly.
api close
]

{ #category : #tests }
MaplessMongoAPITest >> testIsReadWrite [

| api |
api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'.
api open.

self shouldnt: [ api isPrimary ] raise: Error.
self deny: api isReadWrite.
api close
]

{ #category : #tests }
MaplessMongoAPITest >> testIsType [

| api |
api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'.
api open.

self shouldnt: [ api isPrimary ] raise: Error.

self assert: (api isType: #readOnly).
api close
]

{ #category : #tests }
MaplessMongoAPITest >> testResetRole [

| api |
api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'.
api open.

self shouldnt: [ api isPrimary ] raise: Error.

self assert: (api isType: #readOnly).

self shouldnt: [ api resetIsPrimary ] raise: Error.
self shouldnt: [ api isPrimary ] raise: Error.
self assert: (api isType: #readOnly).
api close
]

0 comments on commit 6c2ae8d

Please sign in to comment.