Open Download opened 3 years ago
Got a bit further:
PS C:\ws\versioned-api> npm test
> versioned2@0.0.1 test C:\ws\versioned-api
> npm run lint && npm run unit-test && bash bin/check-deps && npm run api-test
> versioned2@0.0.1 lint C:\ws\versioned-api
> eslint {test/api,app,lib}
> versioned2@0.0.1 unit-test C:\ws\versioned-api
> cross-env NODE_PATH=. jest
PASS lib/assert_types.test.js
PASS app/relationships_helper.test.js
PASS lib/util.test.js
PASS lib/model_spec_schema.test.js
● Console
console.info lib/json_schema.js:68
jsonSchema.formatErrors - could not parse error={
"keyword": "enum",
"dataPath": ".properties['title'].type",
"schemaPath": "#/definitions/simpleTypes/enum",
"params": {
"allowedValues": [
"array",
"boolean",
"integer",
"null",
"number",
"object",
"string"
]
},
"message": "should be equal to one of the allowed values"
} for doc={
"type": "object",
"properties": {
"title": {
"type": "foobar"
}
}
}
console.info lib/json_schema.js:68
jsonSchema.formatErrors - could not parse error={
"keyword": "type",
"dataPath": ".properties['title'].type",
"schemaPath": "#/properties/type/anyOf/1/type",
"params": {
"type": "array"
},
"message": "should be array"
} for doc={
"type": "object",
"properties": {
"title": {
"type": "foobar"
}
}
}
console.info lib/json_schema.js:68
jsonSchema.formatErrors - could not parse error={
"keyword": "anyOf",
"dataPath": ".properties['title'].type",
"schemaPath": "#/properties/type/anyOf",
"params": {},
"message": "should match some schema in anyOf"
} for doc={
"type": "object",
"properties": {
"title": {
"type": "foobar"
}
}
}
PASS lib/json_schema.test.js
PASS lib/model_access.test.js
PASS lib/diff.test.js
PASS lib/coerce.test.js
PASS lib/password_hash.test.js
PASS lib/mongo.test.js
(node:540) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
PASS lib/jwt.test.js
PASS lib/model_callbacks_helper.test.js
PASS lib/model_meta.test.js
PASS app/publish_helper.test.js
Test Suites: 14 passed, 14 total
Tests: 68 passed, 68 total
Snapshots: 0 total
Time: 3.321s, estimated 4s
Ran all test suites.
> versioned2@0.0.1 api-test C:\ws\versioned-api
> cross-env NODE_PATH=. ./test/api/js/run
info: Starting server with config={
"TITLE": "Versioned API",
"DESCRIPTION": "Supports custom content types and versioning",
"NODE_ENV": "test",
"PORT": "3006",
"LOG_LEVEL": "debug",
"CACHE_EXPIRY": "10",
"MONGODB_URL": "mongodb://localhost:27017/versioned2_test",
"JWT_SECRET": "393dabff04884cf89ce918f53924d63e",
"JWT_EXPIRY": 2592000,
"MODELS_LIMIT": 30,
"PROPERTY_LIMIT": 20,
"RATE_LIMIT": null,
"ALGOLIASEARCH_APPLICATION_ID": null,
"ALGOLIASEARCH_API_KEY": null,
"ALGOLIASEARCH_API_KEY_SEARCH": null,
"SENDGRID_API_KEY": null,
"API_BASE_URL": "https://api.versioned.io/v1",
"UI_BASE_URL": "https://app.versioned.io",
"EMAIL_PREFIX": "Versioned",
"EMAIL_ENABLED": false,
"FROM_EMAIL": "noreply@versioned.io",
"CONTACT_EMAIL": "info@versioned.io",
"SYS_ROUTE_KEY": "22b46b0da4",
"modules": {
"logger": {},
"response": {},
"mongo": {}
}
}
Could not connect to mongodb url=mongodb://localhost:27017/versioned2_test err=MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
error: Error thrown when starting server: MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017 { MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
at Timeout.waitQueueMember.timer.setTimeout [as _onTimeout] (C:\ws\versioned-api\node_modules\mongodb\lib\core\sdam\topology.js:430:30)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
name: 'MongoServerSelectionError',
reason:
TopologyDescription {
type: 'Single',
setName: null,
maxSetVersion: null,
maxElectionId: null,
servers: Map { 'localhost:27017' => [ServerDescription] },
stale: false,
compatible: true,
compatibilityError: null,
logicalSessionTimeoutMinutes: null,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
commonWireVersion: null },
[Symbol(mongoErrorContextSymbol)]: {} }
(node:14640) UnhandledPromiseRejectionWarning: MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
at Timeout.waitQueueMember.timer.setTimeout [as _onTimeout] (C:\ws\versioned-api\node_modules\mongodb\lib\core\sda
As you can see, basic stuff is running now on PowerShell but I don't have MongoDB installed. Also, I am not sure whether my changes aren't breaking stuff on Unix/Mac. So I think I will need some help from you to complete this.
For Mongo, we might consider starting a Mongo server with Docker? At my work we are doing this and the nice thing about it is that you can just check out a project and it has a docker-compose.yml file that pulls, installs and starts a Docker image with the database in it and you are all set up.
I'd be willing to try that here but have to know what you think about all this first. Let me make a PR so you can have a look at what I'm doing and see if you agree.
Notice that I'm executing Bash scripts like bin/check-deps by prepending bash
to the command:
bash bin/check-deps
The 'shebang' in the first line of the file has no effect on Windows.... But bash
works as long as you either have Git for Windows or Windows Subsystem for Linux (WSL) installed. Not sure which because I have both... But I wonder whether this breaks on Unix/Mac? If not it's a good solution I think. Let me know your thoughts.
I need to be able to run tests so I can make PRs for this project. So this will be my first PR I think.