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

PL/pg SQL: Add unit test framework (PGUnit), with Docker #137

Merged
merged 12 commits into from
Jan 15, 2020

Conversation

fpellet
Copy link
Contributor

@fpellet fpellet commented Dec 23, 2019

Translate by @acassaigne and me

@GradedJestRisk
Copy link
Contributor

Hi Florian, great minds think alike, eh ?

TLDR
I think both test frameworks can appear there, providing alternatives (xUnit vs TAP syntax) to developers. I'd rather not rename plpgsql to postgresql, because a kata in sql already exists, implemented in postgresql (but can be also done in MysQL or Oracle).

Full version
I saw you use pgUnit, that has few activity https://github.com/adrianandrei-ca/pgunit/. I chose pgTAP cause it looks more active https://github.com/theory/pgtap, but its approach is TAP, different from xUnit, whereas pgUnit is. Anyway, I didn't use it at work so my position is not well informed. Using Docker is also a great idea, glad to see you've done so :°)
So, why not create two subfolders (pgUnit and pgTAP) in plpgsql/test ?

1 similar comment
@GradedJestRisk
Copy link
Contributor

Hi Florian, great minds think alike, eh ?

TLDR
I think both test frameworks can appear there, providing alternatives (xUnit vs TAP syntax) to developers. I'd rather not rename plpgsql to postgresql, because a kata in sql already exists, implemented in postgresql (but can be also done in MysQL or Oracle).

Full version
I saw you use pgUnit, that has few activity https://github.com/adrianandrei-ca/pgunit/. I chose pgTAP cause it looks more active https://github.com/theory/pgtap, but its approach is TAP, different from xUnit, whereas pgUnit is. Anyway, I didn't use it at work so my position is not well informed. Using Docker is also a great idea, glad to see you've done so :°)
So, why not create two subfolders (pgUnit and pgTAP) in plpgsql/test ?

@fpellet
Copy link
Contributor Author

fpellet commented Dec 23, 2019

👍
I will move my code in plpgsql/test/pgunit

@GradedJestRisk
Copy link
Contributor

Hi Florent,

I red your comment on the other PR, I'll keep discussing here to keep all comments together.
I agree with all your comments and can do according changes.

But I think we can even go further and share more structure.
You supplied in pgunit folder the production code and test code together, and used for production code a slightly different implementation: use temporary variables, instead of using the cursor.

I suggest to keep production code separate for test code, ending with:

  • plpgsql/structure : create table
  • plpgsql/src/cursor
  • plpgsql/src/temporary_variable
  • plpgsql/test/pgunit
  • plpgsql/test/pgtap

And last, I saw you put a full test sample, complete with expected and actual (in plpgsql/pgunit/run_tests.sql). IMHO, the kata does not inted to supply the solution, people are expected to build their test suite by themselves.

Anyway, if you don't have time left, or found this over-engineered, or expect everything to be self-supporting, let me know, keep pour PR as-is, I'll update mine according to your structure.

@fpellet
Copy link
Contributor Author

fpellet commented Dec 29, 2019

I prefer to accept the 2 PR before, then create another PR to share the code.
Otherwise, it seems difficult because they will be interdependent.
More, the duplication of this 2 files isn't very important.

@GradedJestRisk
Copy link
Contributor

GradedJestRisk commented Dec 29, 2019 via email

quality_result item.quality%TYPE;
BEGIN
TRUNCATE TABLE item;
CALL new_item('Aged Brie', 4, 6);
Copy link
Owner

Choose a reason for hiding this comment

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

This example test is a little more extensive than the one I usually include in a starting position. I normally have an item called "foo" and an assertion that it is called "fixme" after update quality is called. I prefer this starting test since it fail, and gives the person doing the exercise a big clue as to what to do to make it pass. Then the person doing the exercise has to work out what a better test to write would be. Can you explain why you prefer to start with this test instead?

@emilybache
Copy link
Owner

Hello, thankyou for the pull request. I like the approach of giving a dockerfile for easy setup of the database. I had a small comment about the starting unit test. Do you think you could address that? Also, can both you contributors agree which pull request I should accept, or perhaps I should accept both?

@acassaigne
Copy link
Contributor

Hello,

I agree with your comment concerning the starting unit test.

@GradedJestRisk
Copy link
Contributor

Hi Emily, Anthony and me agreed on this timeline: master / PR136 / PR137.
You can accept PR136 now, and then wait for Anthony to change the unit test on PR317.

@GradedJestRisk
Copy link
Contributor

Anthony, you may change PR name to "PL/pg SQL: Add unit test framework (PGUnit), with Docker"

@fpellet fpellet changed the title Translate plsql to postgresql PL/pg SQL: Add unit test framework (PGUnit), with Docker Jan 14, 2020
@fpellet
Copy link
Contributor Author

fpellet commented Jan 14, 2020

It's done :)

@emilybache emilybache merged commit 9a9b435 into emilybache:master Jan 15, 2020
@emilybache
Copy link
Owner

Thankyou!

@GradedJestRisk
Copy link
Contributor

Hi @acassaigne, look like you create your branch from emilybache, not from my PR.
All pgUnit code has been removed by this PR

lroberts77 pushed a commit to lroberts77/GildedRose-Refactoring-Kata that referenced this pull request Jul 3, 2020
PL/pg SQL: Add unit test framework (PGUnit), with Docker
aflori added a commit to aflori/GildedRose-Refactoring-Kata that referenced this pull request Apr 9, 2024
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.

4 participants