MCPcopy
hub / github.com/kptdev/kpt / TestCmd_execute

Function TestCmd_execute

internal/cmdget/cmdget_test.go:34–70  ·  view source on GitHub ↗

TestCmd_execute tests that get is correctly invoked.

(t *testing.T)

Source from the content-addressed store, hash-verified

32
33// TestCmd_execute tests that get is correctly invoked.
34func TestCmd_execute(t *testing.T) {
35 g, w, clean := testutil.SetupDefaultRepoAndWorkspace(t, testutil.Dataset1)
36 defer clean()
37 dest := filepath.Join(w.WorkspaceDirectory, g.RepoName)
38
39 r := cmdget.NewRunner("kpt")
40 r.Command.SetArgs([]string{"file://" + g.RepoDirectory + ".git/", "./"})
41 err := r.Command.Execute()
42
43 assert.NoError(t, err)
44 g.AssertEqual(t, filepath.Join(g.DatasetDirectory, testutil.Dataset1), dest)
45
46 commit, err := g.GetCommit()
47 assert.NoError(t, err)
48 g.AssertKptfile(t, dest, kptfile.KptFile{
49 ResourceMeta: yaml.ResourceMeta{
50 ObjectMeta: yaml.ObjectMeta{
51 NameMeta: yaml.NameMeta{
52 Name: g.RepoName,
53 },
54 },
55 TypeMeta: yaml.TypeMeta{
56 APIVersion: kptfile.TypeMeta.APIVersion,
57 Kind: kptfile.TypeMeta.Kind},
58 },
59 PackageMeta: kptfile.PackageMeta{},
60 Upstream: kptfile.Upstream{
61 Type: "git",
62 Git: kptfile.Git{
63 Directory: "/",
64 Repo: "file://" + g.RepoDirectory,
65 Ref: "master",
66 Commit: commit, // verify the commit matches the repo
67 },
68 },
69 })
70}
71
72// TestCmdMainBranch_execute tests that get is correctly invoked if default branch
73// is main and master branch doesn't exist

Callers

nothing calls this directly

Calls 6

NewRunnerFunction · 0.92
cleanFunction · 0.85
AssertEqualMethod · 0.80
GetCommitMethod · 0.80
AssertKptfileMethod · 0.45

Tested by

no test coverage detected