omaha: add support for multiple events

add a test and support for multiple events
This commit is contained in:
Brandon Philips 2013-06-25 08:08:19 -07:00
parent 651d843622
commit 51340c1e14
2 changed files with 19 additions and 8 deletions

View file

@ -70,7 +70,7 @@ type App struct {
XMLName xml.Name `xml:"app"`
Ping *Ping `xml:"ping"`
UpdateCheck *UpdateCheck `xml:"updatecheck"`
Event *Event `xml:"event"`
Events []*Event `xml:"event"`
Id string `xml:"appid,attr,omitempty"`
Version string `xml:"version,attr,omitempty"`
NextVersion string `xml:"nextversion,attr,omitempty"`
@ -96,6 +96,12 @@ func (a *App) AddPing() *Ping {
return a.Ping
}
func (a *App) AddEvent() *Event {
event := new(Event)
a.Events = append(a.Events, event)
return event
}
type UpdateCheck struct {
XMLName xml.Name `xml:"updatecheck"`
Urls *Urls `xml:"urls"`

View file

@ -40,7 +40,7 @@ func TestOmahaRequestUpdateCheck(t *testing.T) {
t.Error("developer-build")
}
if v.Apps[0].Event.Type != "3" {
if v.Apps[0].Events[0].Type != "3" {
t.Error("developer-build")
}
}
@ -97,6 +97,10 @@ func ExampleOmaha_NewRequest() {
app := request.AddApp("{27BD862E-8AE8-4886-A055-F7F1A6460627}", "1.0.0.0")
app.AddUpdateCheck()
event := app.AddEvent()
event.Type = "1"
event.Result = "0"
if raw, err := xml.MarshalIndent(request, "", " "); err != nil {
fmt.Println(err)
return
@ -110,6 +114,7 @@ func ExampleOmaha_NewRequest() {
// <os platform="Chrome OS" version="Indy" sp="ForcedUpdate_x86_64"></os>
// <app appid="{27BD862E-8AE8-4886-A055-F7F1A6460627}" version="1.0.0.0">
// <updatecheck></updatecheck>
// <event eventtype="1" eventresult="0"></event>
// </app>
// </request>
}