-
Notifications
You must be signed in to change notification settings - Fork 354
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
chore: add tests for agent_state.go queries #8740
Conversation
✅ Deploy Preview for determined-ui canceled.
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #8740 +/- ##
==========================================
+ Coverage 47.26% 47.41% +0.15%
==========================================
Files 1045 1045
Lines 166700 166689 -11
Branches 2244 2242 -2
==========================================
+ Hits 78783 79034 +251
+ Misses 87759 87497 -262
Partials 158 158
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -667,8 +645,7 @@ func (a *agentState) restoreContainersField() error { | |||
} | |||
|
|||
func clearAgentStates(agentIds []agentID) error { | |||
_, err := db.Bun().NewDelete().Where("agent_id in (?)", agentIds).Exec(context.TODO()) | |||
|
|||
_, err := db.Bun().NewDelete().Model((*agentSnapshot)(nil)).Where("agent_id in (?)", agentIds).Exec(context.TODO()) |
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.
curious did this just not work before?
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.
nope, didn't work at all, i guess.
log.Panicln(err) | ||
} | ||
|
||
err = db.MigrateTestPostgres(pgDB, "file://../../../static/migrations", "up") |
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.
this is a random note and I don't mean to change anything in this PR but I think the hashicorp video had some fact that tests like always assume you are running from some directory?
I guess my point is we shouldn't need to hard code this since we know what directory we are in
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.
we always run from the package directory, or the directory the tests are in. so we can hardcode it exactly like this?
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.
This isn't really related to this PR and should be a follow up ticket, I guess my point is MigrateTestPostgres
shouldn't take a path at all
It should just like traverse its parent directories till it hits master
then find the migrations
Would be cool if it was one line too so like
func TestMain(m testing.M) {
db.TestSetup(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.
yeah that's true
Description
Exactly what it says.
Test Plan
Commentary (optional)
I removed the RP arg to retrieving agent states since restore is enabled by default for every resource pool now (plus, it was wrong, since I don't think it accounted for implicit default pools).
Checklist
docs/release-notes/
.See Release Note for details.
Ticket
DET-10060