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

Simple tests for db/migration #421

Merged
merged 4 commits into from Jan 25, 2021

Conversation

mmlb
Copy link
Contributor

@mmlb mmlb commented Jan 23, 2021

Description

Some quick/shallow test for migration definition.

Why is this needed

#371 introduced a migration where none of the names matched :D, the Id & FuncName was fixed in #383 but that one missed the file name. Why make humans do things they're bad at when instead we can make a computer do something its good at? So this is that :D.

How Has This Been Tested?

Ran go test and it found the bad file name. I artificially changed an Id and the test caught the FuncName|Id mismatch.

How are existing users impacted? What migration steps/scripts do we need?

N/A

Checklist:

I have:

  • updated the documentation and/or roadmap (if required)
  • added unit or e2e tests
  • provided instructions on how to upgrade

Signed-off-by: Manuel Mendez <mmendez@equinix.com>
This way we can add a test to do some basic validations of the
migrate.Migration values.

Signed-off-by: Manuel Mendez <mmendez@equinix.com>
We've had previous commits that introduced migrations where the func
name and migration id did not match, that could be pretty confusing.
Same thing can happen with the file name too. It just seems like a good
idea to make all the timestamp/names match so we can easily go from
migrations in the db to func to file.

Signed-off-by: Manuel Mendez <mmendez@equinix.com>
@codecov
Copy link

codecov bot commented Jan 23, 2021

Codecov Report

Merging #421 (8d7fea1) into master (d9d9077) will increase coverage by 5.25%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #421      +/-   ##
==========================================
+ Coverage   33.08%   38.34%   +5.25%     
==========================================
  Files          24       31       +7     
  Lines        2170     2355     +185     
==========================================
+ Hits          718      903     +185     
  Misses       1376     1376              
  Partials       76       76              
Impacted Files Coverage Δ
...12041103-template-with-same-name-are-acceptable.go 100.00% <ø> (ø)
db/migration/migration.go 100.00% <100.00%> (ø)
...91055-add-partial-unique-constraint-on-template.go 100.00% <0.00%> (ø)
db/migration/202009171251-init-database.go 100.00% <0.00%> (ø)
db/migration/202010221010-add-unique-index.go 100.00% <0.00%> (ø)
...ion/202010071530-init-events-table-and-triggers.go 100.00% <0.00%> (ø)
...gration/2020121691335-update-events-primary-key.go 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9d9077...8d7fea1. Read the comment docs.

Just to play with coverage stats.

Signed-off-by: Manuel Mendez <mmendez@equinix.com>
@mmlb
Copy link
Contributor Author

mmlb commented Jan 23, 2021

According to codecov our migrations have 100% code coverage so that means no bugs right? :D

@mmlb mmlb changed the title db/migration: Rename 20201204... to match the Id Simple tests for db/migration Jan 23, 2021
@gianarb
Copy link
Contributor

gianarb commented Jan 25, 2021

Thanks, I wrote this issue back then when the various bugs you referenced here showed up #414.
Really appreciate seeing this PR coming!

@gianarb gianarb removed the request for review from parauliya January 25, 2021 08:21
@gianarb gianarb added the ready-to-merge Signal to Mergify to merge the PR. label Jan 25, 2021
@mergify mergify bot merged commit 75bf4b6 into tinkerbell:master Jan 25, 2021
@mmlb mmlb deleted the minimal-migration-tests branch January 25, 2021 14:49
@mmlb
Copy link
Contributor Author

mmlb commented Jan 25, 2021

Yep I don't think this'll get us a fix for #414 but sets us up to work on it :D

@mmlb mmlb removed the ready-to-merge Signal to Mergify to merge the PR. label Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants