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

feat: transaction crud #1432

Merged
merged 30 commits into from
Nov 2, 2022
Merged

feat: transaction crud #1432

merged 30 commits into from
Nov 2, 2022

Conversation

mathnogueira
Copy link
Member

This PR...

Changes

Fixes

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

@mathnogueira mathnogueira force-pushed the feat/transaction-crud branch 2 times, most recently from 6998ddf to 6180a55 Compare November 1, 2022 21:02
@mathnogueira mathnogueira marked this pull request as ready for review November 2, 2022 17:34
Copy link
Collaborator

@schoren schoren left a comment

Choose a reason for hiding this comment

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

left 2 nits, but should be good to go!

step_number int NOT NULL,

CONSTRAINT transaction_steps_transactions_fk
FOREIGN KEY (transaction_id, transaction_version) REFERENCES transactions(id, "version")
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't you need an fk here to the tests table?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thing is that the PK of tests are id and version. But as we discussed a couple of days ago, we are always going to use the latest version available. So I decided to not keep the fk here

{
"name": "test-transaction",
"description": "a transaction",
"steps": []
Copy link
Collaborator

Choose a reason for hiding this comment

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

it would be better to have a test here

Copy link
Collaborator

Choose a reason for hiding this comment

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

by test I mean step

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -34,6 +34,139 @@ paths:
$ref: "./definition.yaml#/components/schemas/ExecuteDefinitionResponse"
422:
description: "trying to create a test with an already existing ID"
/transactions:
get:
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the UI design, we are going to need one single endpoint that returns tests and transactions (should support search, pagination, etc.). We could keep the get /transactions endpoint and implement the unified one in a new PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I remember that the idea was to have a single hub for both tests and transactions

Copy link
Collaborator

@xoscar xoscar left a comment

Choose a reason for hiding this comment

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

Hey @mathnogueira great job man!, I left some non-blocking comments!

@@ -34,6 +34,139 @@ paths:
$ref: "./definition.yaml#/components/schemas/ExecuteDefinitionResponse"
422:
description: "trying to create a test with an already existing ID"
/transactions:
get:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I remember that the idea was to have a single hub for both tests and transactions


func (m Model) Transaction(ctx context.Context, in openapi.Transaction) (model.Transaction, error) {
tests := make([]model.Test, len(in.Steps))
for i, testID := range in.Steps {
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't it weird to have db queries a the mappers level? I think this should only set the default values (hydratation) to the object from the request and then the following logic of the controller can do the rest.

Maybe this is something we can address later on 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll try to solve this in another PR

"transaction_steps",
"transactions",
"test_runs",
"tests",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I forgot to add the environments table here, is it necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, it is. I'll add it

@mathnogueira mathnogueira merged commit 278d987 into main Nov 2, 2022
@mathnogueira mathnogueira deleted the feat/transaction-crud branch November 2, 2022 19:51
@mathnogueira mathnogueira mentioned this pull request Nov 2, 2022
4 tasks
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.

None yet

4 participants