Skip to content

Commit

Permalink
Merge pull request #354 from Freezystem/patch-1
Browse files Browse the repository at this point in the history
Add tests for virtual population with mongoose adapter
  • Loading branch information
icebob authored Jul 12, 2023
2 parents 0b5a04a + 7771c3b commit 6ccc04b
Show file tree
Hide file tree
Showing 23 changed files with 237 additions and 13,114 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,12 @@ jobs:
if: ${{ matrix.node-version != '10.x' && matrix.node-version != '12.x' }}

- name: Execute unit tests
run: npm test
run: npm run test:unit

- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: 4.4

- name: Execute integration tests
run: npm run test:integration
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"clean": "lerna clean",
"dev": "nodemon dev.js",
"demo": "node dev.js",
"test": "jest --coverage",
"test:unit": "jest --testMatch \"**/unit/**/*.spec.js\" --coverage",
"test:integration": "jest --testMatch \"**/integration/**/*.spec.js\" --runInBand --coverage",
"ci": "jest --watch",
"coverall": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"init": "cd packages && moleculer init addon",
Expand Down
4 changes: 2 additions & 2 deletions packages/moleculer-db-adapter-mongo/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# 0.4.3 (2019-07-07)

## Changes
- Add `dbName` parameter to constructor. Example: `adapter: new MongoAdapter("mongodb://localhost", { useNewUrlParser: true }, "moleculer-db-demo")`
- Add `dbName` parameter to constructor. Example: `adapter: new MongoAdapter("mongodb://127.0.0.1", { useNewUrlParser: true }, "moleculer-db-demo")`

--------------------------------------------------
<a name="0.4.0"></a>
Expand All @@ -42,7 +42,7 @@

**Example with connection URI**
```js
new MongoDBAdapter("mongodb://localhost/moleculer-db")
new MongoDBAdapter("mongodb://127.0.0.1/moleculer-db")
```

**Example with connection URI & options**
Expand Down
4 changes: 2 additions & 2 deletions packages/moleculer-db-adapter-mongo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const broker = new ServiceBroker();
broker.createService({
name: "posts",
mixins: [DbService],
adapter: new MongoDBAdapter("mongodb://localhost/moleculer-demo"),
adapter: new MongoDBAdapter("mongodb://127.0.0.1/moleculer-demo"),
collection: "posts"
});

Expand All @@ -50,7 +50,7 @@ broker.start()

**Example with connection URI**
```js
new MongoDBAdapter("mongodb://localhost/moleculer-db")
new MongoDBAdapter("mongodb://127.0.0.1/moleculer-db")
```

**Example with connection URI & options**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let broker = new ServiceBroker({
// Load my service
broker.createService(StoreService, {
name: "posts",
adapter: new MongoAdapter("mongodb://localhost/moleculer-db-demo", { useNewUrlParser: true }),
adapter: new MongoAdapter("mongodb://127.0.0.1/moleculer-db-demo", { useNewUrlParser: true }),
collection: "posts",
settings: {
fields: ["_id", "title", "content", "votes", "status", "updatedAt"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let broker = new ServiceBroker({
broker.createService({
name: "users",
mixins: [DbService],
adapter: new MongoDBAdapter("mongodb://localhost/search-test"),
adapter: new MongoDBAdapter("mongodb://127.0.0.1/search-test"),
collection: "users",

methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let adapter;
// Load my service
broker.createService(StoreService, {
name: "posts",
adapter: new MongoAdapter("mongodb://localhost", { useNewUrlParser: true }, "moleculer-db-demo"),
adapter: new MongoAdapter("mongodb://127.0.0.1", { useNewUrlParser: true }, "moleculer-db-demo"),
collection: "posts",
settings: {},

Expand Down
4 changes: 2 additions & 2 deletions packages/moleculer-db-adapter-mongo/test/unit/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("Test MongoDbAdapter", () => {
collection: "posts"
});

const uri = "mongodb://localhost";
const uri = "mongodb://127.0.0.1";
const opts = {};
const adapter = new MongoDbAdapter(uri, opts, "db-name");

Expand Down Expand Up @@ -109,7 +109,7 @@ describe("Test MongoDbAdapter", () => {
adapter.dbName = undefined;
return adapter.connect().catch(protectReject).then(() => {
expect(MongoClient).toHaveBeenCalledTimes(1);
expect(MongoClient).toHaveBeenCalledWith("mongodb://localhost", undefined);
expect(MongoClient).toHaveBeenCalledWith("mongodb://127.0.0.1", undefined);

expect(adapter.client).toBe(fakeConn);
expect(adapter.client.connect).toHaveBeenCalledTimes(1);
Expand Down
2 changes: 1 addition & 1 deletion packages/moleculer-db-adapter-mongoose/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $ npm install moleculer-db moleculer-db-adapter-mongoose mongoose --save

**Example with connection URI**
```js
new MongooseAdapter("mongodb://localhost/moleculer-db")
new MongooseAdapter("mongodb://127.0.0.1/moleculer-db")
```

**Example with URI and options**
Expand Down
4 changes: 2 additions & 2 deletions packages/moleculer-db-adapter-mongoose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const broker = new ServiceBroker();
broker.createService({
name: "posts",
mixins: [DbService],
adapter: new MongooseAdapter("mongodb://localhost/moleculer-demo"),
adapter: new MongooseAdapter("mongodb://127.0.0.1/moleculer-demo"),
model: mongoose.model("Post", mongoose.Schema({
title: { type: String },
content: { type: String },
Expand All @@ -53,7 +53,7 @@ broker.start()

**Example with connection URI**
```js
new MongooseAdapter("mongodb://localhost/moleculer-db")
new MongooseAdapter("mongodb://127.0.0.1/moleculer-db")
```

**Example with URI and options**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const broker = new ServiceBroker({
// Load my service
broker.createService(StoreService, {
name: "posts",
adapter: new MongooseAdapter("mongodb://localhost/moleculer-db-demo"),
adapter: new MongooseAdapter("mongodb://127.0.0.1/moleculer-db-demo"),
model: Post,
settings: {
fields: ["_id", "title", "content", "votes", "status", "updatedAt"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let users = [];
// Load my service
broker.createService(StoreService, {
name: "posts",
adapter: new MongooseAdapter("mongodb://localhost/moleculer-db-demo"),
adapter: new MongooseAdapter("mongodb://127.0.0.1/moleculer-db-demo"),
//dependencies: ["users"],
model: Post,
settings: {
Expand Down Expand Up @@ -54,7 +54,7 @@ broker.createService(StoreService, {
// Load my service
broker.createService(StoreService, {
name: "users",
adapter: new MongooseAdapter("mongodb://localhost/moleculer-db-demo"),
adapter: new MongooseAdapter("mongodb://127.0.0.1/moleculer-db-demo"),
model: User,
settings: {
fields: ["_id", "username", "fullName", "email"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let broker = new ServiceBroker({
broker.createService({
name: "users",
mixins: [DbService],
adapter: new MongooseDBAdapter("mongodb://localhost/search2-test"),
adapter: new MongooseDBAdapter("mongodb://127.0.0.1/search2-test"),
model: User,

methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let adapter;
// Load my service
broker.createService(StoreService, {
name: "posts",
adapter: new MongooseAdapter("mongodb://localhost/moleculer-db-demo",{
adapter: new MongooseAdapter("mongodb://127.0.0.1/moleculer-db-demo",{
useNewUrlParser: true,
useUnifiedTopology: true
}),
Expand Down
Loading

0 comments on commit 6ccc04b

Please sign in to comment.