Skip to content

Conversation

nightnei
Copy link
Contributor

@nightnei nightnei commented Apr 8, 2021

No description provided.

@nightnei nightnei requested a review from StyleT April 8, 2021 07:58
@nightnei nightnei force-pushed the feature/supportFewDomains_registry branch from e1dae5b to 1f7a734 Compare April 8, 2021 08:00
@nightnei nightnei force-pushed the feature/supportFewDomains_registry branch from 1f7a734 to 337fa88 Compare April 8, 2021 08:03
Copy link
Contributor

@StyleT StyleT left a comment

Choose a reason for hiding this comment

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

undo approval :)

Base automatically changed from feature/supportFewDomains to feature/supportFewDomains_master April 8, 2021 08:18
next: boolean,
templateName: string,
}
// now it's useless
Copy link
Contributor

Choose a reason for hiding this comment

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

So let's remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

const getAllRouterDomains = async (req: Request, res: Response): Promise<void> => {
const routerDomains = await db.select().from('router_domains');

res.setHeader('Content-Range', routerDomains.length); //Stub for future pagination capabilities
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add pagination from very beginning. It's much easier to do it now.

Copy link
Contributor

Choose a reason for hiding this comment

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

See example settings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -25,7 +26,7 @@ router.get('/', async (req, res) => {
routes: [] as any[],
specialRoutes: {},
settings: {},
routerDomains: {},
routerDomains,
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, what if instead of adding routerDomains property to config - we would turn domainId: int field into domain: string | null for respective routes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

on the one hand, I think it's good idea, but on the other hand it will be a little bit harder to detect inside ILC - "do we respect the current domain".

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, why so?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -6,3 +6,4 @@ export { default as sharedProps } from '../sharedProps/routes';
export { default as authEntities } from '../authEntities/routes';
export { default as settings } from '../settings/routes';
export { default as versioning } from '../versioning/routes';
export { default as routerDomains } from '../routerDomains/routes';
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you also need to add filtration capability by domainId to getRoutes API

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, can't understand, what do you mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

I want to be able to filter routes list by domainId, in routes API

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

domainId,
};

let response = await request.post(example.url)
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be within another try/finally block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

expect(response.body).deep.equal(expectedRoute);
} finally {
await request.delete(example.url + id);
await request.delete(example.routerDomain.url + domainId).expect(204);
Copy link
Contributor

Choose a reason for hiding this comment

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

rm expect here, it's not necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but what if delete is broken? in this case we will face the problem with the next it, instead of current

Copy link
Contributor

Choose a reason for hiding this comment

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

We should have an explicit test case for delete operation instead of this implicit check, IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -469,6 +556,32 @@ describe(`Tests ${example.url}`, () => {
}
});

it('should successfully update record with existed domainId', async () => {
const domainId1 = await createRouterDomain(example.routerDomain);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, you need to do proper cleanup in case of error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

});

it('should successfully create record', async () => {
const responseCreation = await request.post(example.url)
Copy link
Contributor

Choose a reason for hiding this comment

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

ensure cleanup in case of test failure with try/finally. Here and in all tests below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@nightnei nightnei requested a review from StyleT April 8, 2021 15:10
@@ -412,6 +478,30 @@ describe(`Tests ${example.url}`, () => {
}
});

it('should not update record with non-existing domainId', async () => {
const domainId = await createRouterDomain(example.routerDomain);
Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't see cleanup code for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

});

it('should create record with existed domainId', async () => {
const domainId = await createRouterDomain(example.routerDomain);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, I assume we need to cleanup this too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@nightnei nightnei requested a review from StyleT April 12, 2021 19:11
Copy link
Contributor

@StyleT StyleT left a comment

Choose a reason for hiding this comment

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

Nice job 👍

@nightnei nightnei merged commit 8ebb3c3 into feature/supportFewDomains_master Apr 12, 2021
@nightnei nightnei deleted the feature/supportFewDomains_registry branch April 12, 2021 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants