• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang gt.File函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/kardianos/govendor/internal/gt.File函数的典型用法代码示例。如果您正苦于以下问题:Golang File函数的具体用法?Golang File怎么用?Golang File使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了File函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestTagList

func TestTagList(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
		gt.File("a_test.go", "testing", "bytes"),
		gt.FileBuild("b.go", "appengine", "encoding/hex"),
	)
	g.Setup("co2/pk1",
		gt.File("a_not_test_foo.go", "encoding/csv"),
		gt.File("a_test.go", "testing", "encoding/json"),
		gt.FileBuild("b.go", "appengine", "encoding/binary"),
	)
	g.In("co1")
	c := ctx(g)
	c.IgnoreBuild("test appengine")

	list(g, c, "co1 list", `e co2/pk1 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s encoding/csv < ["co2/pk1"]
s encoding/hex < ["co1/pk1"]
s testing < ["co1/pk1"]
`)
}
开发者ID:tedoc2000,项目名称:govendor,代码行数:26,代码来源:context_test.go


示例2: TestUnused

func TestUnused(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
	)
	g.Setup("co1/vendor/a",
		gt.File("a.go", "encoding/csv"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "bytes"),
	)
	g.Setup("co3/pk1",
		gt.File("a.go", "strings"),
	)

	g.In("co1")
	c := ctx(g)

	g.Check(c.ModifyImport("co2/pk1", Add))
	g.Check(c.ModifyImport("co3/pk1", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after add", `
v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
u co1/vendor/a [a] < []
u co1/vendor/co3/pk1 [co3/pk1] < []
l co1/pk1 < []
s bytes < ["co1/vendor/co2/pk1"]
s encoding/csv < ["co1/vendor/a"]
s strings < ["co1/vendor/co3/pk1"]
`)
}
开发者ID:jpillora,项目名称:govendor,代码行数:35,代码来源:context_test.go


示例3: TestDuplicatePackage

func TestDuplicatePackage(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co3/pk1"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "co3/pk1"),
	)
	g.Setup("co3/pk1",
		gt.File("a.go", "strings"),
	)
	g.In("co2")
	Vendor(g, "co2 init", "init", "")
	Vendor(g, "co2 add", "add +ext", "")

	g.In("co1")
	Vendor(g, "co1 init", "init", "")
	Vendor(g, "co1 pre list", "list", `e co2/pk1
e co3/pk1
e co3/pk1
l co1/pk1
`)
	Vendor(g, "co1 add", "add -long +ext", "")
	Vendor(g, "co1 list", "list", `v co2/pk1
v co3/pk1
l co1/pk1
`)
}
开发者ID:leeprovoost,项目名称:govendor,代码行数:30,代码来源:run_test.go


示例4: TestTagAdd15

func TestTagAdd15(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
		gt.File("a_test.go", "bytes", "testing"),
		gt.FileBuild("b.go", "appengine", "encoding/csv"),
	)
	g.In("co1")
	c := ctx15(g)
	c.IgnoreBuild("test appengine")

	g.Check(c.ModifyImport("co2/pk1", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after add", `v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
l co1/pk1 < []
s strings < ["co1/vendor/co2/pk1"]
`)

	checkPathBase := filepath.Join(g.Current(), "vendor", "co2", "pk1")
	if _, err := os.Stat(filepath.Join(checkPathBase, "a_test.go")); err == nil {
		t.Error("a_test.go should not be copied into vendor folder")
	}
	if _, err := os.Stat(filepath.Join(checkPathBase, "b.go")); err == nil {
		t.Error("b.go should not be copied into vendor folder")
	}
}
开发者ID:kouhin,项目名称:govendor,代码行数:33,代码来源:context_test.go


示例5: TestVendorProgram

func TestVendorProgram(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/main",
		gt.File("b.go", "bytes"),
	)
	g.In("co1")
	c := ctx(g)

	g.Check(c.ModifyImport("co2/main", AddUpdate))

	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 list", `
p co1/vendor/co2/main [co2/main] < []
l co1/pk1 < []
s bytes < ["co1/vendor/co2/main"]
s strings < ["co1/pk1"]
`)
}
开发者ID:tedoc2000,项目名称:govendor,代码行数:25,代码来源:context_test.go


示例6: TestEllipsis

func TestEllipsis(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co2/pk1/pk2"),
		gt.File("b.go", "co2/pk1", "bytes"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk1/pk2",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	Vendor(g, "co1 init", "init", "")
	Vendor(g, "", "list", `e co2/pk1
e co2/pk1/pk2
l co1/pk1
`)
	Vendor(g, "co1 add ext", "add co2/pk1/...", "")
	Vendor(g, "co1 list", "list", `v co2/pk1
v co2/pk1/pk2
l co1/pk1
`)
}
开发者ID:leeprovoost,项目名称:govendor,代码行数:26,代码来源:run_test.go


示例7: TestImportSimple15

func TestImportSimple15(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co2/pk2"),
		gt.File("b.go", "co2/pk1", "bytes"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk2",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	c := ctx15(g)
	g.Check(c.ModifyImport("co2/pk1", AddUpdate))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())
	expected := `v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
e co2/pk2 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co1/vendor/co2/pk1" "co2/pk2"]
`
	list(g, c, "same", expected)

	c = ctx15(g)
	list(g, c, "new", expected)

	vendorFile15(g, `{
	"comment": "",
	"ignore": "",
	"package": [
		{
			"canonical": "co2/pk1",
			"comment": "",
			"local": "vendor/co2/pk1",
			"revision": "",
			"revisionTime": ""
		}
	]
}`)

	// Now remove an import.
	g.Check(c.ModifyImport("co2/pk1", Remove))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())
	list(g, c, "co1 remove", `e co2/pk1 < ["co1/pk1"]
e co2/pk2 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co2/pk1" "co2/pk2"]
`)
}
开发者ID:kouhin,项目名称:govendor,代码行数:55,代码来源:context_test.go


示例8: TestVendor

func TestVendor(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
		gt.File("b.go", "bytes"),
	)
	g.Setup("co2/vendor/a",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "a"),
	)

	g.In("co1")
	c := ctx(g)

	list(g, c, "co1 list", `e co2/pk1 < ["co1/pk1"]
e co2/vendor/a [a] < ["co2/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co2/vendor/a"]
`)

	g.Check(c.ModifyImport("co2/pk1", Add))
	g.Check(c.ModifyImport("co2/vendor/a", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after add", `v co1/vendor/a [a] < ["co1/vendor/co2/pk1"]
v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co1/vendor/a"]
`)

	vendorFile(g, `{
	"comment": "",
	"ignore": "",
	"package": [
		{
			"origin": "co2/vendor/a",
			"path": "a",
			"revision": ""
		},
		{
			"path": "co2/pk1",
			"revision": ""
		}
	]
}
`)
}
开发者ID:tedoc2000,项目名称:govendor,代码行数:54,代码来源:context_test.go


示例9: TestTree

func TestTree(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk1/c_code",
		gt.File("stub.c"),
	)
	g.Setup("co2/pk1/go_code",
		gt.File("stub.go", "strings"),
	)
	g.In("co1")
	c := ctx(g)

	g.Check(c.ModifyImport("co2/pk1/^", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after add list", `
v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
u co1/vendor/co2/pk1/go_code [co2/pk1/go_code] < []
l co1/pk1 < []
s strings < ["co1/vendor/co2/pk1" "co1/vendor/co2/pk1/go_code"]
`)
	tree(g, c, "co1 after add tree", `
/pk1/a.go
/vendor/co2/pk1/a.go
/vendor/co2/pk1/c_code/stub.c
/vendor/co2/pk1/go_code/stub.go
/vendor/vendor.json
`)

	g.Check(c.ModifyImport("co2/pk1", Remove))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	tree(g, c, "co1 after remove tree", `
/pk1/a.go
/vendor/vendor.json
`)
}
开发者ID:jpillora,项目名称:govendor,代码行数:46,代码来源:context_test.go


示例10: TestMissing

func TestMissing(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co3/pk1"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "bytes"),
	)
	g.Setup("co3/pk1",
		gt.File("a.go", "strings"),
	)

	g.In("co1")
	c := ctx(g)

	g.Check(c.ModifyImport("co2/pk1", Add))
	g.Check(c.ModifyImport("co3/pk1", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after add", `
v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
v co1/vendor/co3/pk1 [co3/pk1] < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/vendor/co2/pk1"]
s strings < ["co1/vendor/co3/pk1"]
`)

	g.In("co1")
	c = ctx(g)

	g.Remove("co1/vendor/co2/pk1")

	g.Remove("co1/vendor/co3/pk1")
	g.Remove("co3/pk1")

	list(g, c, "co1 after remove", `
e co2/pk1 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co2/pk1"]
m co3/pk1 < ["co1/pk1"]
`)
}
开发者ID:jpillora,项目名称:govendor,代码行数:45,代码来源:context_test.go


示例11: TestImportSimple

func TestImportSimple(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co2/pk2"),
		gt.File("b.go", "co2/pk1", "bytes"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk2",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	c := ctx14(g)
	g.Check(c.ModifyImport("co2/pk1", AddUpdate))

	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	vendorFile14(g, `{
	"comment": "",
	"ignore": "",
	"package": [
		{
			"path": "co2/pk1",
			"revision": ""
		}
	]
}`)

	expected := `v co1/internal/co2/pk1 [co2/pk1] < ["co1/pk1"]
e co2/pk2 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co1/internal/co2/pk1" "co2/pk2"]
`

	list(g, c, "same", expected)

	c = ctx14(g)
	list(g, c, "new", expected)
}
开发者ID:fabxc,项目名称:govendor,代码行数:44,代码来源:context_test.go


示例12: TestRemove

func TestRemove(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	c := ctx(g)

	g.Check(c.ModifyImport("co2/pk1", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	g.In("co2/pk1")
	// Change directory to let windows delete directory.
	current := g.Current()
	g.In("co1")
	err := os.RemoveAll(current)
	if err != nil {
		g.Fatal(err)
	}

	g.Check(c.ModifyImport("co2/pk1", Remove))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	vi, err := os.Stat(filepath.Join(c.RootDir, c.VendorFolder))
	if err != nil {
		t.Fatal("vendor folder should still be present", err)
	}
	if vi.IsDir() == false {
		t.Fatal("vendor folder is not a dir")
	}
}
开发者ID:tedoc2000,项目名称:govendor,代码行数:38,代码来源:context_test.go


示例13: TestSimple

func TestSimple(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co2/pk2"),
		gt.File("b.go", "co2/pk1", "bytes"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk2",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	c := ctx14(g)
	list(g, c, "initial", `e co2/pk1 < ["co1/pk1"]
e co2/pk2 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co2/pk1" "co2/pk2"]
`)
}
开发者ID:fabxc,项目名称:govendor,代码行数:23,代码来源:context_test.go


示例14: TestAddMissing

func TestAddMissing(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
	)
	g.In("co1")
	c := ctx(g)

	err := c.ModifyImport("co2/pk1", Add)
	if _, is := err.(ErrNotInGOPATH); !is {
		t.Fatalf("Expected not in GOPATH error. Got %v", err)
	}
}
开发者ID:tedoc2000,项目名称:govendor,代码行数:15,代码来源:context_test.go


示例15: TestTagList15

func TestTagList15(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1/pk2"),
		gt.File("a_test.go", "testing", "co2/pk1", "bytes"),
		gt.FileBuild("b.go", "appengine", "encoding/binary"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "encoding/csv"),
	)
	g.Setup("co2/pk1/pk2",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	c := ctx15(g)
	c.IgnoreBuild("test appengine")

	list(g, c, "co1 list", `e co2/pk1/pk2 < ["co1/pk1"]
l co1/pk1 < []
s strings < ["co2/pk1/pk2"]
`)
}
开发者ID:kouhin,项目名称:govendor,代码行数:24,代码来源:context_test.go


示例16: TestDuplicatePackage

func TestDuplicatePackage(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk2", "co3/pk3"),
	)
	g.Setup("co2/pk2",
		gt.File("b.go", "co3/pk3"),
	)
	g.Setup("co3/pk3",
		gt.File("c.go", "strings"),
	)
	g.In("co2")
	c := ctx(g)
	statusList, err := c.Status()
	g.Check(err)
	for _, item := range statusList {
		if item.Status != StatusExternal {
			continue
		}
		g.Check(c.ModifyImport(item.Local, AddUpdate))
	}
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	vendorFile(g, `{
	"comment": "",
	"ignore": "",
	"package": [
		{
			"path": "co3/pk3",
			"revision": ""
		}
	]
}
`)

	list(g, c, "co2 list", `
v co2/vendor/co3/pk3 [co3/pk3] < ["co2/pk2"]
l co2/pk2 < []
s strings < ["co2/vendor/co3/pk3"]
`)

	g.In("co1")
	c = ctx(g)
	list(g, c, "co1 pre list", `
e co2/pk2 < ["co1/pk1"]
e co2/vendor/co3/pk3 [co3/pk3] < ["co2/pk2"]
e co3/pk3 < ["co1/pk1"]
l co1/pk1 < []
s strings < ["co2/vendor/co3/pk3" "co3/pk3"]
`)

	statusList, err = c.Status()
	g.Check(err)
	for _, item := range statusList {
		if item.Status != StatusExternal {
			continue
		}
		g.Check(c.ModifyImport(item.Local, AddUpdate))
	}
	c.ResloveApply(ResolveAutoLongestPath(c.Check())) // Automaically resolve conflicts.
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())
	vendorFile(g, `{
	"comment": "",
	"ignore": "",
	"package": [
		{
			"path": "co2/pk2",
			"revision": ""
		},
		{
			"origin": "co1/vendor/co3/pk3",
			"path": "co3/pk3",
			"revision": ""
		}
	]
}
`)

	expected := `
v co1/vendor/co2/pk2 [co2/pk2] < ["co1/pk1"]
v co1/vendor/co3/pk3 [co3/pk3] < ["co1/pk1" "co1/vendor/co2/pk2"]
l co1/pk1 < []
s strings < ["co1/vendor/co3/pk3"]
`

	list(g, c, "co1 list 1", expected)
	c = ctx(g)
	list(g, c, "co1 list 2", expected)

	// Now remove one import.
	g.Check(c.ModifyImport("co3/pk3", Remove))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())
	list(g, c, "co1 remove", `v co1/vendor/co2/pk2 [co2/pk2] < ["co1/pk1"]
e co3/pk3 < ["co1/pk1" "co1/vendor/co2/pk2"]
l co1/pk1 < []
//.........这里部分代码省略.........
开发者ID:tedoc2000,项目名称:govendor,代码行数:101,代码来源:context_test.go


示例17: TestUpdate

func TestUpdate(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co2/pk1/pk2"),
		gt.File("b.go", "co2/pk1", "bytes"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk1/pk2",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	c := ctx(g)
	g.Check(c.ModifyImport("co2/pk1", Add))
	g.Check(c.ModifyImport("co2/pk1/pk2", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after add", `
v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
v co1/vendor/co2/pk1/pk2 [co2/pk1/pk2] < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co1/vendor/co2/pk1" "co1/vendor/co2/pk1/pk2"]
`)

	vendorFile(g, `{
	"comment": "",
	"ignore": "",
	"package": [
		{
			"path": "co2/pk1",
			"revision": ""
		},
		{
			"path": "co2/pk1/pk2",
			"revision": ""
		}
	]
}
`)

	g.Setup("co2/pk1/pk2",
		gt.File("a.go", "strings", "encoding/csv"),
	)

	// Update an import.
	g.Check(c.ModifyImport("co2/pk1/pk2", Update))
	ct := 0
	for _, op := range c.Operation {
		if op.State == OpDone {
			continue
		}
		ct++
	}
	if ct != 1 {
		t.Fatal("Must only have a single operation. Has", ct)
	}
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after update", `
v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
v co1/vendor/co2/pk1/pk2 [co2/pk1/pk2] < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s encoding/csv < ["co1/vendor/co2/pk1/pk2"]
s strings < ["co1/vendor/co2/pk1" "co1/vendor/co2/pk1/pk2"]
`)

	// Now remove an import.
	g.Check(c.ModifyImport("co2/pk1", Remove))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())
	list(g, c, "co1 remove", `v co1/vendor/co2/pk1/pk2 [co2/pk1/pk2] < ["co1/pk1"]
e co2/pk1 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s encoding/csv < ["co1/vendor/co2/pk1/pk2"]
s strings < ["co1/vendor/co2/pk1/pk2" "co2/pk1"]
`)
}
开发者ID:jpillora,项目名称:govendor,代码行数:85,代码来源:context_test.go


示例18: TestVendorFile

func TestVendorFile(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
		gt.File("b.go", "bytes"),
	)
	g.Setup("a",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "a"),
	)

	g.In("co2")
	c := ctx(g)
	g.Check(c.ModifyImport("a", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	// Ensure we import from vendor folder.
	// TODO: add test with "a" in GOPATH to ensure vendor folder pref.
	g.Remove("a")

	g.In("co1")
	c = ctx(g)
	list(g, c, "co1 list", `e co2/pk1 < ["co1/pk1"]
e co2/vendor/a [a] < ["co2/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co2/vendor/a"]
`)

	g.Check(c.ModifyImport("co2/pk1", Add))
	g.Check(c.ModifyImport("co2/vendor/a", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after add", `v co1/vendor/a [a] < ["co1/vendor/co2/pk1"]
v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co1/vendor/a"]
`)

	vendorFile(g, `{
	"comment": "",
	"ignore": "",
	"package": [
		{
			"origin": "co2/vendor/a",
			"path": "a",
			"revision": ""
		},
		{
			"path": "co2/pk1",
			"revision": ""
		}
	]
}
`)
}
开发者ID:tedoc2000,项目名称:govendor,代码行数:63,代码来源:context_test.go


示例19: TestUpdate

func TestUpdate(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co2/pk1/pk2"),
		gt.File("b.go", "co2/pk1", "bytes"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk1/pk2",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	c := ctx(g)
	g.Check(c.ModifyImport("co2/pk1", Add))
	g.Check(c.ModifyImport("co2/pk1/pk2", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after add", `
v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
v co1/vendor/co2/pk1/pk2 [co2/pk1/pk2] < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co1/vendor/co2/pk1" "co1/vendor/co2/pk1/pk2"]
`)

	vendorFile(g, `{
	"comment": "",
	"ignore": "",
	"package": [
		{
			"path": "co2/pk1",
			"revision": ""
		},
		{
			"path": "co2/pk1/pk2",
			"revision": ""
		}
	]
}
`)

	g.Setup("co1/vendor/co2/pk1/pk2",
		gt.File("a.go", "strings", "encoding/csv"),
	)

	// Update an import.
	g.Check(c.ModifyImport("co2/pk1/pk2", Update))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after update", `
v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
v co1/vendor/co2/pk1/pk2 [co2/pk1/pk2] < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s encoding/csv < ["co1/vendor/co2/pk1/pk2"]
s strings < ["co1/vendor/co2/pk1" "co1/vendor/co2/pk1/pk2"]
`)

	// Now remove an import.
	g.Check(c.ModifyImport("co2/pk1", Remove))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())
	list(g, c, "co1 remove", `v co1/vendor/co2/pk1/pk2 [co2/pk1/pk2] < ["co1/pk1"]
e co2/pk1 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s encoding/csv < ["co1/vendor/co2/pk1/pk2"]
s strings < ["co1/vendor/co2/pk1/pk2" "co2/pk1"]
`)
}
开发者ID:tedoc2000,项目名称:govendor,代码行数:75,代码来源:context_test.go



注:本文中的github.com/kardianos/govendor/internal/gt.File函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gt.New函数代码示例发布时间:2022-05-23
下一篇:
Golang params.ModuleParams类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap