TestCmdMainBranch_execute tests that get is correctly invoked if default branch is main and master branch doesn't exist
(t *testing.T)
| 72 | // TestCmdMainBranch_execute tests that get is correctly invoked if default branch |
| 73 | // is main and master branch doesn't exist |
| 74 | func TestCmdMainBranch_execute(t *testing.T) { |
| 75 | // set up git repository with master and main branches |
| 76 | g, w, clean := testutil.SetupDefaultRepoAndWorkspace(t, testutil.Dataset1) |
| 77 | defer clean() |
| 78 | dest := filepath.Join(w.WorkspaceDirectory, g.RepoName) |
| 79 | err := g.CheckoutBranch("main", false) |
| 80 | if !assert.NoError(t, err) { |
| 81 | t.FailNow() |
| 82 | } |
| 83 | err = g.DeleteBranch("master") |
| 84 | if !assert.NoError(t, err) { |
| 85 | t.FailNow() |
| 86 | } |
| 87 | |
| 88 | r := cmdget.NewRunner("kpt") |
| 89 | r.Command.SetArgs([]string{"file://" + g.RepoDirectory + ".git/", "./"}) |
| 90 | err = r.Command.Execute() |
| 91 | |
| 92 | assert.NoError(t, err) |
| 93 | g.AssertEqual(t, filepath.Join(g.DatasetDirectory, testutil.Dataset1), dest) |
| 94 | |
| 95 | commit, err := g.GetCommit() |
| 96 | assert.NoError(t, err) |
| 97 | g.AssertKptfile(t, dest, kptfile.KptFile{ |
| 98 | ResourceMeta: yaml.ResourceMeta{ |
| 99 | ObjectMeta: yaml.ObjectMeta{ |
| 100 | NameMeta: yaml.NameMeta{ |
| 101 | Name: g.RepoName, |
| 102 | }, |
| 103 | }, |
| 104 | TypeMeta: yaml.TypeMeta{ |
| 105 | APIVersion: kptfile.TypeMeta.APIVersion, |
| 106 | Kind: kptfile.TypeMeta.Kind}, |
| 107 | }, |
| 108 | PackageMeta: kptfile.PackageMeta{}, |
| 109 | Upstream: kptfile.Upstream{ |
| 110 | Type: "git", |
| 111 | Git: kptfile.Git{ |
| 112 | Directory: "/", |
| 113 | Repo: "file://" + g.RepoDirectory, |
| 114 | Ref: "main", |
| 115 | Commit: commit, // verify the commit matches the repo |
| 116 | }, |
| 117 | }, |
| 118 | }) |
| 119 | |
| 120 | } |
| 121 | |
| 122 | func TestCmd_stdin(t *testing.T) { |
| 123 | d, err := ioutil.TempDir("", "kpt") |
nothing calls this directly
no test coverage detected