-
Notifications
You must be signed in to change notification settings - Fork 135
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
Unit tests for resource Get requests #412
Conversation
Codecov Report
@@ Coverage Diff @@
## master #412 +/- ##
==========================================
+ Coverage 29.90% 33.04% +3.13%
==========================================
Files 24 24
Lines 2170 2170
==========================================
+ Hits 649 717 +68
+ Misses 1445 1377 -68
Partials 76 76
Continue to review full report at Codecov.
|
db/hardware_test.go
Outdated
var wg sync.WaitGroup | ||
wg.Add(len(s.Input)) | ||
for _, hw := range s.Input { | ||
if s.InputAsync { |
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.
You are using InputAsync
with a GetByID
? Can you rephrase it? It does not have a lot of sense for me
} | ||
}(ctx, tinkDB, hw) | ||
} else { | ||
wg.Done() |
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.
Overall I don't understand what you are doing. You should check what you expect as part of the table
test. Not here
db/template_test.go
Outdated
wg.Add(len(s.Input)) | ||
for _, in := range s.Input { | ||
if s.InputAsync { | ||
go func(t *testing.T, ctx context.Context, tt *workflow.Workflow, tinkDB *db.TinkDB) { |
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.
Same as before, it does not have sense to use InputAsync
here because you are not doing any input.
7246941
to
2d30ee0
Compare
db/hardware_test.go
Outdated
@@ -211,6 +204,192 @@ func TestDeleteHardware(t *testing.T) { | |||
} | |||
} | |||
|
|||
type getFunc func(c context.Context, db *db.TinkDB, in *hardware.Hardware) (string, error) | |||
|
|||
func TestGetHardware(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.
You are testing different functions in the same test and that's not good practice, please split the functions you are testing in their own test case (keep table testing as well) thanks
0899b8f
to
8cd6bae
Compare
Signed-off-by: Gaurav Gahlot <[email protected]>
Signed-off-by: Gaurav Gahlot <[email protected]>
c72be29
to
c0f1118
Compare
db/workflow_test.go
Outdated
} | ||
} | ||
|
||
func TestGetWorkflow_WithNonExistingID(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 move this test here TestGetWorkflow
? it is just another variant of the table test.
Signed-off-by: Gaurav Gahlot <[email protected]>
c0f1118
to
44073a7
Compare
Description
The PR adds unit tests for
Get
requests to resources (template, hardware, workflow).Restructures the tests in #361 as per the new framework.
Checklist:
I have: