omaha: embed test data into the test code
This commit is contained in:
parent
f26efba60f
commit
909299725c
1 changed files with 12 additions and 11 deletions
|
@ -3,22 +3,23 @@ package omaha
|
|||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
const SampleRequest = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<request protocol="3.0" version="ChromeOSUpdateEngine-0.1.0.0" updaterversion="ChromeOSUpdateEngine-0.1.0.0" installsource="ondemandupdate" ismachine="1">
|
||||
<os version="Indy" platform="Chrome OS" sp="ForcedUpdate_x86_64"></os>
|
||||
<app appid="{87efface-864d-49a5-9bb3-4b050a7c227a}" bootid="{7D52A1CC-7066-40F0-91C7-7CB6A871BFDE}" machineid="{8BDE4C4D-9083-4D61-B41C-3253212C0C37}" oem="ec3000" version="ForcedUpdate" track="dev-channel" from_track="developer-build" lang="en-US" board="amd64-generic" hardware_class="" delta_okay="false" >
|
||||
<ping active="1" a="-1" r="-1"></ping>
|
||||
<updatecheck targetversionprefix=""></updatecheck>
|
||||
<event eventtype="3" eventresult="2" previousversion=""></event>
|
||||
</app>
|
||||
</request>
|
||||
`
|
||||
|
||||
func TestOmahaRequestUpdateCheck(t *testing.T) {
|
||||
file, err := os.Open("../fixtures/update-engine/update/request.xml")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
fix, err := ioutil.ReadAll(file)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
v := Request{}
|
||||
xml.Unmarshal(fix, &v)
|
||||
xml.Unmarshal([]byte(SampleRequest), &v)
|
||||
|
||||
if v.Os.Version != "Indy" {
|
||||
t.Error("Unexpected version", v.Os.Version)
|
||||
|
|
Loading…
Reference in a new issue