本文整理匯總了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)
}
}
}