aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorjw2552018-04-23 13:54:17 +0100
committerjw2552018-04-23 13:54:17 +0100
commitfac0433557ac9556d48a9bb2421ac96ff220786d (patch)
tree20ec191c4945f926d0bb21a5f29e792308bf543f /test
parentremoved R_eport (diff)
downloadmedicine-fac0433557ac9556d48a9bb2421ac96ff220786d.tar.gz
medicine-fac0433557ac9556d48a9bb2421ac96ff220786d.zip

fixed various tests and errors

Diffstat (limited to 'test')
-rw-r--r--test/integration/auth.routes.test.ts4
-rw-r--r--test/integration/protocol.routes.test.ts9
-rw-r--r--test/postman.json56
-rw-r--r--test/test-db.ts26
4 files changed, 61 insertions, 34 deletions
diff --git a/test/integration/auth.routes.test.ts b/test/integration/auth.routes.test.ts
index 29c0cfc..c090984 100644
--- a/test/integration/auth.routes.test.ts
+++ b/test/integration/auth.routes.test.ts
@@ -80,10 +80,10 @@ describe('authentication', () => {
grant_type: 'password'
}).then((res) => {
// File-not-found is a valid response
- expect(res).to.have.status(404);
+ expect(res).to.have.status(401);
}).catch((reason) => {
// Unauthorised is a valid response
- expect(reason).to.have.status(401);
+ expect(reason).to.have.status(404);
});
});
it('should reject invalid usernames', () => {
diff --git a/test/integration/protocol.routes.test.ts b/test/integration/protocol.routes.test.ts
index 77b39f0..882d680 100644
--- a/test/integration/protocol.routes.test.ts
+++ b/test/integration/protocol.routes.test.ts
@@ -100,11 +100,12 @@ const completeProtocol: MochaForEachInput[] = [
'debug',
'info',
'security',
- 'warning',
+ 'warn',
'error',
'critical',
'success',
- 'failure'
+ 'failure',
+ 'verbose'
]),
message: types.anything,
label: optional(types.string),
@@ -215,8 +216,8 @@ const completeProtocol: MochaForEachInput[] = [
}, 200],
['post', '/projects/mocky2', {}, 200],
['get', '/projects/mocky/properties', null, 200],
- ['post', '/projects/mocky/files/foler/file?action=overwrite', {}, 200],
- ['get', '/projects/mocky/files/foler/file', null, 200]
+ ['post', '/projects/mocky/files/file?overwrite=true&truncate=true', {}, 200],
+ ['get', '/projects/mocky/files/file', null, 200]
//['get', '/projects/mocky/files_by_id/file1', null, 200]
];
diff --git a/test/postman.json b/test/postman.json
index 6d8541b..e0960ba 100644
--- a/test/postman.json
+++ b/test/postman.json
@@ -2,7 +2,7 @@
"variables": [],
"info": {
"name": "JH",
- "_postman_id": "d9fad1ce-92af-fc2c-ff74-074fc681c7ee",
+ "_postman_id": "5676ae95-d7b9-baa0-5688-08862c569679",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
@@ -15,14 +15,14 @@
"name": "/projects/",
"request": {
"url": {
- "raw": "{{host}}/{{endpoint}}/projects/other?action=create",
+ "raw": "{{host}}/{{endpoint}}/projects/{{dummy_project}}?action=create",
"host": [
"{{host}}"
],
"path": [
"{{endpoint}}",
"projects",
- "other"
+ "{{dummy_project}}"
],
"query": [
{
@@ -58,7 +58,7 @@
{
"name": "/projects/abc/files",
"request": {
- "url": "{{host}}/{{endpoint}}/projects/{{dummy_project}}/files/file",
+ "url": "{{host}}/{{endpoint}}/projects/{{dummy_project}}/files/text",
"method": "POST",
"header": [
{
@@ -68,21 +68,15 @@
},
{
"key": "Content-Type",
- "value": "application/json",
- "description": "",
- "disabled": true
+ "value": "text/plain",
+ "description": ""
}
],
"body": {
- "mode": "formdata",
- "formdata": [
- {
- "key": "userfile",
- "description": "",
- "type": "file",
- "src": "checker_black.jpg"
- }
- ]
+ "mode": "file",
+ "file": {
+ "src": ""
+ }
},
"description": ""
},
@@ -179,7 +173,10 @@
"description": ""
}
],
- "body": {},
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
"description": ""
},
"response": []
@@ -217,7 +214,10 @@
"disabled": true
}
],
- "body": {},
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
"description": ""
},
"response": []
@@ -235,7 +235,10 @@
"disabled": true
}
],
- "body": {},
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
"description": ""
},
"response": []
@@ -252,7 +255,10 @@
"description": ""
}
],
- "body": {},
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
"description": ""
},
"response": []
@@ -296,7 +302,10 @@
"url": "{{host}}/",
"method": "GET",
"header": [],
- "body": {},
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
"description": ""
},
"response": []
@@ -313,7 +322,10 @@
"description": ""
}
],
- "body": {},
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
"description": ""
},
"response": []
diff --git a/test/test-db.ts b/test/test-db.ts
index ef980c5..9a32cb2 100644
--- a/test/test-db.ts
+++ b/test/test-db.ts
@@ -2,7 +2,12 @@ import { default as Project } from '../src/db/model/Project';
import { default as User } from '../src/db/model/User';
import { default as UserGroup } from '../src/db/model/UserGroup';
import { default as File } from '../src/db/model/File';
+import { View, addSubFileToFolder, copyFile, createProjectFolder, deleteFile,
+ saveFile, views, preprocess } from '../src/files';
+import * as fs from 'fs-extra';
import { FileTypeName } from '../src/files';
+import { uuid } from '../src/uuid';
+
import { Sequelize } from 'sequelize-typescript';
import * as sqlite from 'sqlite3';
@@ -37,14 +42,15 @@ export interface Projec {
contributors: Credentials[];
creationDate: Date;
lastActivity: Date;
+ rootFolderId: string;
}
export interface Filee {
- name: string,
- path: string,
- uuid: string,
- creator: Credentials,
- type: FileTypeName
+ name: string;
+ path: string;
+ uuid: string;
+ creator: Credentials;
+ type: FileTypeName;
}
export const addUser: (database?: Database, admin?: boolean) =>
@@ -92,11 +98,19 @@ export const addProjec: (database: Database, user: Credentials) =>
Promise<Projec> = async(
database: Database, user: Credentials
): Promise<Projec> => {
+ createProjectFolder('mocky');
+ const file: File = new File({
+ uuid: uuid.generate()
+ });
+ file.mimetype = 'inode/directory';
+ file.name = '';
+ await file.save();
const mockProject: Projec = {
name: 'mocky',
contributors: [user],
creationDate: new Date(),
- lastActivity: new Date()
+ lastActivity: new Date(),
+ rootFolderId: file.uuid
};
await new Project(mockProject).save();