当前位置: 首页>>代码示例>>Golang>>正文


Golang Target.Set方法代码示例

本文整理汇总了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)
		}
	}
}
开发者ID:4shome,项目名称:go.jiri,代码行数:59,代码来源:manifest_test.go

示例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)
		}
	}
}
开发者ID:vanadium,项目名称:go.jiri,代码行数:53,代码来源:manifest_test.go


注:本文中的v/io/jiri/profiles.Target.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。