-
Notifications
You must be signed in to change notification settings - Fork 137
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
Fixed the duplicate name issue while creating a template #270
Conversation
Name of the template which is used to provide with -n flag while creating a template should be unique. But there was an issue because of which it was accepting duplicate name as well. This PR fixed the above issue. Signed-off-by: parauliya <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #270 +/- ##
==========================================
+ Coverage 15.34% 17.08% +1.74%
==========================================
Files 9 9
Lines 1264 1264
==========================================
+ Hits 194 216 +22
+ Misses 1059 1036 -23
- Partials 11 12 +1
Continue to review full report at Codecov.
|
Pretty good! Can you add a Table Test that accepts templates as input and validate the answers, please? Let's make this coverage green bit by bit! |
6eb7d25
to
dd74eb6
Compare
grpc-server/template_test.go
Outdated
timeout: 60` | ||
) | ||
|
||
func TestDuplicateTemplateName(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you call it TestCreateTemplate
? and the table test has to work like this imho:
Table Test is not only for one specific use case, but it has to be flexible enough to allow all the one you can think about for the function you are testing, in our case CreateTemplate
// you don't need a testCases struct just use a []testCase
struct testCase type {
db mock.DB
name string
input []string // or templates
expect func() (*template.CreateResponse, error)
}
In order to figure out if the TableTest is well written can you add three other testcases please?
- Well formatted and successful template creation (only one)
- A random validation error if we have any
- Create 2 templates with a different name, both should work
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I will try to add couple of more test cases as you suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gianarb As mentioned by you I have modified the test struct ( not exactly as you suggested ) so that in future more tests can be added. And I have also added couple of more test cases. But I was not able to test for validation of template because we don't check the validation of a template in CreateTemplate
function. Template is being validated while creating a workflow here https://github.com/tinkerbell/tink/blob/master/db/workflow.go#L98.
Signed-off-by: parauliya <[email protected]>
3782f9e
to
c714e35
Compare
Signed-off-by: parauliya <[email protected]>
0d61ae6
to
d06e1b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thanks +1.74%
✅
Name of the template which is used to provide with -n flag while creating a template should be unique.
But there was an issue because of which it was accepting duplicate name as well.
This PR fixed the above issue.
Signed-off-by: parauliya [email protected]
Description
Name of the template which is used to provide with -n flag while creating a template should be unique.
But there was an issue because of which it was accepting duplicate name as well.
This PR fixed the above issue.
Why is this needed
Same as Description.
How Has This Been Tested?
I tried to create multiple template with same name but now they are not being created because of the same name.
How are existing users impacted? What migration steps/scripts do we need?
User need to provide the unique name for each template it is creating in the database.
Checklist:
I have: