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

Pipelines: Test coverage of Pipelines API endpoint #2209

Merged
merged 7 commits into from
Jun 1, 2023

Conversation

Pezmc
Copy link
Contributor

@Pezmc Pezmc commented Jun 1, 2023

Description

Originally added in: #2082

This PR adds comprehensive test coverage of the Pipelines API, catching and fixing a few bugs and API improvements along the way.

Related Issue(s)

Fixes #2171 for #2124

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • [-] Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • [-] Changes flowforge.yml?
    • Issue/PR raised on flowforge/helm to update ConfigMap Template
    • Issue/PR raised on flowforge/CloudProject to update values for Staging/Production

Labels

  • Backport needed? -> add the backport label
  • Includes a DB migration? -> add the area:migration label

@Pezmc Pezmc requested review from knolleary and joepavitt June 1, 2023 13:03
@@ -7,7 +7,15 @@ module.exports = {
schema: {
name: {
type: DataTypes.STRING,
allowNull: false
allowNull: false,
validate: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Validation being handled at a model rather than controller level, is a pattern I would like us to start repeating throughout our codebase. @knolleary @Steve-Mcl @joepavitt

Copy link
Contributor

@Steve-Mcl Steve-Mcl Jun 1, 2023

Choose a reason for hiding this comment

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

@Pezmc I have no argument but can I trouble you to provide a little context please? I am not 100% on sequelize models and controllers and how every single piece fits together. I am assuming you raised this as you are aware of some best practice & it would improve our code quality and ... ?

Ta.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! Ultimately it is the model that is being validated, having validations and constraints at the model (and database level) means we can be 100% confident that all of our models are meeting the validation.

Right now, we usually validate the user input at the controller level, but there's nothing stopping an "invalid" model from being created, it also leads to duplicate validation logic spread throughout the app (e.g. to check a name is provided). Centralising this validation reduces code duplication, while also making our models more reliable.

Happy to spin up a separate issue (or drop into a huddle) to discuss further! I might end up writing this up as part of a "best practices" doc for us (thoughts @ZJvandeWeg @knolleary?)

Copy link
Member

Choose a reason for hiding this comment

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

Controller validation should be done for security purposes and user feedback.

Models are indeed the level to validate on a table scale. There's always going the be some overlap.

Our code base has fairly fat controllers sadly, and do too much heavy lifting. More logic should reside in the model layer for a higher quality code base.

This should be documented indeed in developer docs. Would be great to do to raise the quality of contributions

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks Pez.

@knolleary knolleary merged commit 4049f7d into main Jun 1, 2023
2 of 3 checks passed
@knolleary knolleary deleted the test-2171-pipelines-api branch June 1, 2023 18:34
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.

Pipelines: Happy path E2E test coverage
4 participants