blob: 713fb55da75ac48d456b07242e4d8d7c82f67d40 [file] [log] [blame]
package repo_test
import (
"encoding/xml"
"strings"
"testing"
"github.com/google/go-cmp/cmp"
"go.fuchsia.dev/infra/cmd/jiri2repo/repo"
)
func TestParseManifestFile(t *testing.T) {
input := `
<manifest>
<remote name="android"
fetch=".."
review="sso://android/" />
<remote name="fuchsia"
fetch=".."
review="sso://fuchsia"
revision="deadbeef" />
<project name="integration"
path="integration-path" />
<project name="fuchsia"
path="fuchsia-path"
remote="fuchsia-remote"
revision="fuchsia-revision" />
</manifest>
`
want := repo.Manifest{
XMLName: xml.Name{
Space: "",
Local: "manifest",
},
Remote: []repo.Remote{
{
Name: "android",
Fetch: "..",
Review: "sso://android/",
},
{
Name: "fuchsia",
Fetch: "..",
Review: "sso://fuchsia",
},
},
Project: []repo.Project{
{
Name: "integration",
Path: "integration-path",
},
{
Name: "fuchsia",
Path: "fuchsia-path",
Remote: "fuchsia-remote",
Revision: "fuchsia-revision",
},
},
}
var got repo.Manifest
if err := repo.ParseManifest(strings.NewReader(input), &got); err != nil {
t.Fatal(err)
}
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("ParseManifestFile() mismatch (-want +got):\n%s", diff)
}
}