本文整理汇总了Golang中v/io/jiri/profiles.Target.Set方法的典型用法代码示例。如果您正苦于以下问题:Golang Target.Set方法的具体用法?Golang Target.Set怎么用?Golang Target.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v/io/jiri/profiles.Target
的用法示例。
在下文中一共展示了Target.Set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestBackwardsCompatibility
func TestBackwardsCompatibility(t *testing.T) {
profiles.Clear()
getProfiles := func() []*profiles.Profile {
db := []*profiles.Profile{}
names := profiles.Profiles()
sort.Strings(names)
for _, name := range names {
db = append(db, profiles.LookupProfile(name))
}
return db
}
ctx := tool.NewDefaultContext()
if err := profiles.Read(ctx, "./testdata/legacy.xml"); err != nil {
t.Fatal(err)
}
if got, want := profiles.SchemaVersion(), profiles.Original; got != want {
t.Errorf("got %v, want %v", got, want)
}
oprofiles := getProfiles()
if got, want := len(oprofiles), 5; got != want {
t.Errorf("got %v, want %v", got, want)
}
filename := tmpFile()
defer os.RemoveAll(filepath.Dir(filename))
var t1 profiles.Target
t1.Set("tag=cpu,os")
profiles.AddProfileTarget("__first", t1)
if err := profiles.Write(ctx, filename); err != nil {
t.Fatal(err)
}
if err := profiles.Read(ctx, filename); err != nil {
t.Fatal(err)
}
if got, want := profiles.SchemaVersion(), profiles.V3; got != want {
t.Errorf("got %v, want %v", got, want)
}
nprofiles := getProfiles()
if got, want := len(nprofiles), 6; got != want {
t.Errorf("got %v, want %v", got, want)
}
if got, want := nprofiles[0].Name, "__first"; got != want {
t.Errorf("got %v, want %v", got, want)
}
for i, v := range nprofiles[1:] {
if got, want := v.Name, oprofiles[i].Name; got != want {
t.Errorf("got %v, want %v", got, want)
}
}
}
示例2: TestReadingV0
func TestReadingV0(t *testing.T) {
pdb := profiles.NewDB()
jirix, cleanup := jiritest.NewX(t)
defer cleanup()
if err := pdb.Read(jirix, "./testdata/legacy.xml"); err != nil {
t.Fatal(err)
}
if got, want := pdb.SchemaVersion(), profiles.Original; got != want {
t.Errorf("got %v, want %v", got, want)
}
oprofiles := pdb.Profiles()
if got, want := len(oprofiles), 5; got != want {
t.Errorf("got %v, want %v", got, want)
}
filename := tmpFile()
defer os.RemoveAll(filepath.Dir(filename))
var t1 profiles.Target
t1.Set("[email protected]")
pdb.InstallProfile("", "__first", "")
if err := pdb.AddProfileTarget("", "__first", t1); err != nil {
t.Fatal(err)
}
if err := pdb.Write(jirix, "", filename); err != nil {
t.Fatal(err)
}
if err := pdb.Read(jirix, filename); err != nil {
t.Fatal(err)
}
if got, want := pdb.SchemaVersion(), profiles.V5; got != want {
t.Errorf("got %v, want %v", got, want)
}
nprofiles := pdb.Profiles()
if got, want := len(nprofiles), 6; got != want {
t.Fatalf("got %v, want %v", got, want)
}
if got, want := nprofiles[0].Name(), "__first"; got != want {
t.Errorf("got %v, want %v", got, want)
}
for i, v := range nprofiles[1:] {
if got, want := v.Name(), oprofiles[i].Name(); got != want {
t.Errorf("got %v, want %v", got, want)
}
}
}