feat(omaha): test and change the name of the event field

test out the event field and change its name to avoid repitition.
This commit is contained in:
Brandon Philips 2013-03-29 05:51:29 -07:00
parent d1b8d0aa1b
commit 5cb5b5c4e9
2 changed files with 18 additions and 4 deletions

View file

@ -40,13 +40,15 @@ func (r *Request) AddApp(a *App) {
type App struct { type App struct {
XMLName xml.Name `xml:"app"` XMLName xml.Name `xml:"app"`
UpdateCheck *UpdateCheck `xml:"updatecheck"` UpdateCheck *UpdateCheck `xml:"updatecheck"`
Ping *Ping Event *Event `xml:"event"`
Ping *Ping `xml:"ping"`
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"`
Lang string `xml:"lang,attr,omitempty"` Lang string `xml:"lang,attr,omitempty"`
Client string `xml:"client,attr,omitempty"` Client string `xml:"client,attr,omitempty"`
InstallAge string `xml:"installage,attr,omitempty"` InstallAge string `xml:"installage,attr,omitempty"`
FromTrack string `xml:"from_track,attr,omitempty"`
} }
func NewApp(id string, version string) *App { func NewApp(id string, version string) *App {
@ -92,8 +94,8 @@ func (a *App) AddPing() {
type Event struct { type Event struct {
XMLName xml.Name `xml:"event"` XMLName xml.Name `xml:"event"`
EventType string `xml:"eventtype,attr,omitempty"` Type string `xml:"eventtype,attr,omitempty"`
EventResult string `xml:"eventresult,attr,omitempty"` Result string `xml:"eventresult,attr,omitempty"`
PreviousVersion string `xml:"previousversion,attr,omitempty"` PreviousVersion string `xml:"previousversion,attr,omitempty"`
} }

View file

@ -8,7 +8,7 @@ import (
"os" "os"
) )
func TestOmahaUpdateCheck(t *testing.T) { func TestOmahaRequestUpdateCheck(t *testing.T) {
file, err := os.Open("fixtures/update-engine/update/request.xml") file, err := os.Open("fixtures/update-engine/update/request.xml")
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@ -31,6 +31,18 @@ func TestOmahaUpdateCheck(t *testing.T) {
if v.Apps[0].UpdateCheck == nil { if v.Apps[0].UpdateCheck == nil {
t.Error("Expected an UpdateCheck") t.Error("Expected an UpdateCheck")
} }
if v.Apps[0].Version != "ForcedUpdate" {
t.Error("Verison is ForcedUpdate")
}
if v.Apps[0].FromTrack != "developer-build" {
t.Error("developer-build")
}
if v.Apps[0].Event.Type != "3" {
t.Error("developer-build")
}
} }
func ExampleOmaha_NewRequest() { func ExampleOmaha_NewRequest() {