Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface for model collection with tests #141

Open
wants to merge 13 commits into
base: collections
Choose a base branch
from

Conversation

costascaio
Copy link
Contributor

No description provided.

@costascaio costascaio self-assigned this Jul 22, 2020
@rgaiacs rgaiacs changed the base branch from master to collections July 22, 2020 20:31
@rgaiacs rgaiacs added the enhancement New feature or request label Jul 22, 2020
@rgaiacs rgaiacs added this to the v3.0.0 milestone Jul 22, 2020
@rgaiacs rgaiacs linked an issue Jul 22, 2020 that may be closed by this pull request
4 tasks
Copy link
Contributor

@rgaiacs rgaiacs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start. Some comments are related with style. Your code is valid but we prefer the other style.

I will add more comments later.

"Test CollectionModel",
() => {

/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this comment.

})
.then(
data => {
expecte(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail because Sequelize is configured to return a query object instead of JSON. You need to use data.dataValues.

})
.then(
data => {
expecte(data).toBeNull();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are expecting .toThrow(error?) instead of .toBeNull().

})
.then(
data => {
expecte(data).toBeNull();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are expecting .toThrow(error?) instead of .toBeNull().

})
.then(
data => {
expecte(data).toBeNull();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default should be public and the missing field should go to the default one.

})
.then(
data => {
expecte(data).toBeNull();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are expecting .toThrow(error?) instead of .toBeNull().

}
);

/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start a new describe block.

@rgaiacs
Copy link
Contributor

rgaiacs commented Jul 22, 2020

$ git remote -v           
caio	[email protected]:costascaio/searchable-image-database-nodejs.git (fetch)
caio	[email protected]:costascaio/searchable-image-database-nodejs.git (push)
origin	[email protected]:CRICDatabase/searchable-image-database-nodejs.git (fetch)
origin	[email protected]:CRICDatabase/searchable-image-database-nodejs.git (push)

@costascaio I rebased the origin/collection to origin/master without hit any conflict using

$ git checkout origin/collection
$ git rebase origin/master

Your pull request is now against the rebased version.

@rgaiacs rgaiacs mentioned this pull request Jul 22, 2020
2 tasks
Copy link
Contributor

@rgaiacs rgaiacs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You changed src/repositorios/injury.test.js but not src/repositorios/image.test.js.

@@ -14,7 +14,8 @@ describe(
{
nome: "Short",
detalhes: "Long",
grade: 100
grade: 100,
id_collection: 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test might fail if collection doesn't exist. Fix it using #136.

@@ -25,7 +26,8 @@ describe(
id: expect.any(Number),
nome: "Short",
detalhes: "Long",
grade: 100
grade: 100,
id_collection: 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test might fail if collection doesn't exist. Fix it using #136.

@@ -47,7 +49,8 @@ describe(
id: 1,
nome: expect.any(String),
detalhes: expect.any(String),
grade: expect.any(Number)
grade: expect.any(Number),
id_collection: expect.any(Number)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test might fail if collection doesn't exist. Fix it using #136.

@@ -87,7 +90,8 @@ describe(
id: expect.any(Number),
nome: expect.any(String),
detalhes: expect.any(String),
grade: expect.any(Number)
grade: expect.any(Number),
id_collection: expect.any(Number)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test might fail if collection doesn't exist. Fix it using #136.

@@ -93,23 +94,25 @@ module.exports = {
});
},

async cadastrarCelulaSegmentada(id_imagem, id_descricao) {
async cadastrarCelulaSegmentada(id_imagem, id_descricao, id_collection) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cadastrarCelulaSegmentada doesn't need id_collection. Check the model!

});
},

async cadastrarCelulaClassificada(id_imagem, id_lesao) {
async cadastrarCelulaClassificada(id_imagem, id_lesao, id_collection) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function was removed during the simplification of the database schema.

@@ -0,0 +1,162 @@
"use strict";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File name has a typo. Rename it from src/repositorios/colllection.test.js to src/repositorios/collection.test.js.

Copy link
Contributor

@rgaiacs rgaiacs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use sed -i 's/expecte/expect/' src/repositorios/colllection.test.js to fix the typos.

})
.then(
data => {
expecte(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here. Replace expecte with expect.

})
.then(
data => {
expecte(data).toBeNull();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here. Replace expecte with expect.

})
.then(
data => {
expecte(data).toBeNull();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here. Replace expecte with expect.

})
.then(
data => {
expecte(data).toBeNull();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here. Replace expecte with expect.

})
.then(
data => {
expecte(data).toBeNull();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here. Replace expecte with expect.

})
.then(
data => {
expecte(data).toBeNull();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here. Replace expecte with expect.

@rgaiacs
Copy link
Contributor

rgaiacs commented Aug 17, 2020

@costascaio I rebased the collections branch in this repository. You must update your local copy:

$ git remote -v
origin	[email protected]:CRICDatabase/searchable-image-database-nodejs.git (fetch)
origin	[email protected]:CRICDatabase/searchable-image-database-nodejs.git (push)
$ git fetch origin
$ git checkout collection
$ git rebase origin/collections

And resolve the conflicts.

return CollectionModel.findByPk(id_collection);
},

async update_collection(request){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add toggle_public_collection(id_collection).

return CollectionDOA.create_collection({
name: "Jest",
slang: "jest",
public: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default for public should be false.

)
}
);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_collection without public is missing.

}
);

test(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move get_collection to their own suite (inside describe).

expect(data.dataValues)
.toMatchObject(
{
id: expect.any(Number),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace

id: expect.any(Number),

with

id: 1,

return CollectionModel.create(collection);
},

async delete_collection(id_collection){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to mark for deletion instead of delete. Need to add a new field delete.

);
}
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed test delete_collection.

@@ -246,72 +263,3 @@ describe(

}
);


describe(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should not be delete.

@rgaiacs
Copy link
Contributor

rgaiacs commented Sep 7, 2020

@costascaio Any update?

@rgaiacs
Copy link
Contributor

rgaiacs commented Sep 21, 2020

@costascaio you merge instead of rebase. Please fix it.

@rgaiacs
Copy link
Contributor

rgaiacs commented Sep 24, 2020

@costascaio please follow the steps

$ git remote -v
caio	[email protected]:costascaio/searchable-image-database-nodejs.git (fetch)
caio	[email protected]:costascaio/searchable-image-database-nodejs.git (push)
origin	[email protected]:CRICDatabase/searchable-image-database-nodejs.git (fetch)
origin	[email protected]:CRICDatabase/searchable-image-database-nodejs.git (push)
$ git checkout origin/master
$ git branch -f master
$ git branch -f collection
$ git cherry-pick e900588
$ git cherry-pick fa0e227
$ git cherry-pick 9c5f7fe
```

You need to fix the conflict in `src/repositorios/image.test.js`.

```
$ git add src/repositorios/image.test.js
$ git commit
$ git cherry-pick 85583d0
```

You need to resolve `src/models/CollectionModel.js` and `src/repositorios/image.test.js`.

```
$ git add
$ git commit
$ git cherry-pick 30fa851
```

You need to resolve `src/fixtures/collection.json`.

```
$ git add
$ git commit
$ git push -f caio collection
```

@costascaio costascaio force-pushed the collection branch 2 times, most recently from 3cb42f9 to a0027d1 Compare September 24, 2020 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add interface for model collection
3 participants