omaha: add support for multiple events
add a test and support for multiple events
This commit is contained in:
parent
651d843622
commit
51340c1e14
2 changed files with 19 additions and 8 deletions
|
@ -70,7 +70,7 @@ type App struct {
|
||||||
XMLName xml.Name `xml:"app"`
|
XMLName xml.Name `xml:"app"`
|
||||||
Ping *Ping `xml:"ping"`
|
Ping *Ping `xml:"ping"`
|
||||||
UpdateCheck *UpdateCheck `xml:"updatecheck"`
|
UpdateCheck *UpdateCheck `xml:"updatecheck"`
|
||||||
Event *Event `xml:"event"`
|
Events []*Event `xml:"event"`
|
||||||
Id string `xml:"appid,attr,omitempty"`
|
Id string `xml:"appid,attr,omitempty"`
|
||||||
Version string `xml:"version,attr,omitempty"`
|
Version string `xml:"version,attr,omitempty"`
|
||||||
NextVersion string `xml:"nextversion,attr,omitempty"`
|
NextVersion string `xml:"nextversion,attr,omitempty"`
|
||||||
|
@ -96,6 +96,12 @@ func (a *App) AddPing() *Ping {
|
||||||
return a.Ping
|
return a.Ping
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) AddEvent() *Event {
|
||||||
|
event := new(Event)
|
||||||
|
a.Events = append(a.Events, event)
|
||||||
|
return event
|
||||||
|
}
|
||||||
|
|
||||||
type UpdateCheck struct {
|
type UpdateCheck struct {
|
||||||
XMLName xml.Name `xml:"updatecheck"`
|
XMLName xml.Name `xml:"updatecheck"`
|
||||||
Urls *Urls `xml:"urls"`
|
Urls *Urls `xml:"urls"`
|
||||||
|
|
|
@ -40,7 +40,7 @@ func TestOmahaRequestUpdateCheck(t *testing.T) {
|
||||||
t.Error("developer-build")
|
t.Error("developer-build")
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.Apps[0].Event.Type != "3" {
|
if v.Apps[0].Events[0].Type != "3" {
|
||||||
t.Error("developer-build")
|
t.Error("developer-build")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,10 @@ func ExampleOmaha_NewRequest() {
|
||||||
app := request.AddApp("{27BD862E-8AE8-4886-A055-F7F1A6460627}", "1.0.0.0")
|
app := request.AddApp("{27BD862E-8AE8-4886-A055-F7F1A6460627}", "1.0.0.0")
|
||||||
app.AddUpdateCheck()
|
app.AddUpdateCheck()
|
||||||
|
|
||||||
|
event := app.AddEvent()
|
||||||
|
event.Type = "1"
|
||||||
|
event.Result = "0"
|
||||||
|
|
||||||
if raw, err := xml.MarshalIndent(request, "", " "); err != nil {
|
if raw, err := xml.MarshalIndent(request, "", " "); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
|
@ -110,6 +114,7 @@ func ExampleOmaha_NewRequest() {
|
||||||
// <os platform="Chrome OS" version="Indy" sp="ForcedUpdate_x86_64"></os>
|
// <os platform="Chrome OS" version="Indy" sp="ForcedUpdate_x86_64"></os>
|
||||||
// <app appid="{27BD862E-8AE8-4886-A055-F7F1A6460627}" version="1.0.0.0">
|
// <app appid="{27BD862E-8AE8-4886-A055-F7F1A6460627}" version="1.0.0.0">
|
||||||
// <updatecheck></updatecheck>
|
// <updatecheck></updatecheck>
|
||||||
|
// <event eventtype="1" eventresult="0"></event>
|
||||||
// </app>
|
// </app>
|
||||||
// </request>
|
// </request>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue