Fix agent updating (#3287)

This commit is contained in:
qwerty287 2024-01-28 12:29:56 +01:00 committed by GitHub
parent 94b882fb95
commit 2eec1ce909
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View file

@ -25,7 +25,7 @@ type Agent struct {
Platform string `json:"platform" xorm:"VARCHAR(100) 'platform'"`
Backend string `json:"backend" xorm:"VARCHAR(100) 'backend'"`
Capacity int32 `json:"capacity" xorm:"capacity"`
Version string `json:"version" xorm:"version"`
Version string `json:"version" xorm:"'version'"`
NoSchedule bool `json:"no_schedule" xorm:"no_schedule"`
} // @name Agent

View file

@ -87,3 +87,22 @@ func TestAgentList(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 1, len(agents))
}
func TestAgentUpdate(t *testing.T) {
store, closer := newTestStore(t, new(model.Agent))
defer closer()
agent := &model.Agent{
ID: int64(1),
Name: "test",
Token: "secret-token",
}
err := store.AgentCreate(agent)
assert.NoError(t, err)
agent.Backend = "local"
agent.Capacity = 2
agent.Version = "next-abcdef"
err = store.AgentUpdate(agent)
assert.NoError(t, err)
}