client: send "Complete" event in update checks

Needed in order to match update_engine behavior.
This commit is contained in:
Michael Marineau 2017-06-08 17:12:59 -07:00
parent d946c1e7b2
commit a2f653da34
3 changed files with 25 additions and 1 deletions

View file

@ -206,6 +206,11 @@ func (ac *AppClient) UpdateCheck() (*omaha.UpdateResponse, error) {
app.AddPing()
app.AddUpdateCheck()
// Tell CoreUpdate to consider us in its "Complete" state,
// otherwise it interprets ping as "Instance-Hold" which is
// nonsense when we are sending an update check!
app.Events = append(app.Events, EventComplete)
ac.sentPing = true
appResp, err := ac.doReq(ac.apiEndpoint, req)

View file

@ -100,6 +100,15 @@ func TestClientNoUpdate(t *testing.T) {
if len(r.checks) != 1 {
t.Fatalf("expected 1 update check, not %d", len(r.checks))
}
if len(r.events) != 1 {
t.Fatalf("expected 1 event, not %d", len(r.events))
}
if r.events[0].Type != omaha.EventTypeUpdateComplete ||
r.events[0].Result != omaha.EventResultSuccessReboot {
t.Fatalf("expected %#v, not %#v", EventComplete, r.events[0])
}
}
func TestClientWithUpdate(t *testing.T) {
@ -132,6 +141,15 @@ func TestClientWithUpdate(t *testing.T) {
if len(r.checks) != 1 {
t.Fatalf("expected 1 update check, not %d", len(r.checks))
}
if len(r.events) != 1 {
t.Fatalf("expected 1 event, not %d", len(r.events))
}
if r.events[0].Type != omaha.EventTypeUpdateComplete ||
r.events[0].Result != omaha.EventResultSuccessReboot {
t.Fatalf("expected %#v, not %#v", EventComplete, r.events[0])
}
}
func TestClientPing(t *testing.T) {