(t *testing.T)
| 108 | } |
| 109 | |
| 110 | func TestCmd_failUnCommitted(t *testing.T) { |
| 111 | g, w, clean := testutil.SetupDefaultRepoAndWorkspace(t, testutil.Dataset1) |
| 112 | defer clean() |
| 113 | dest := filepath.Join(w.WorkspaceDirectory, g.RepoName) |
| 114 | |
| 115 | // clone the repo |
| 116 | getCmd := cmdget.NewRunner("kpt") |
| 117 | getCmd.Command.SetArgs([]string{"file://" + g.RepoDirectory + ".git", w.WorkspaceDirectory}) |
| 118 | err := getCmd.Command.Execute() |
| 119 | if !assert.NoError(t, err) { |
| 120 | return |
| 121 | } |
| 122 | if !g.AssertEqual(t, filepath.Join(g.DatasetDirectory, testutil.Dataset1), dest) { |
| 123 | return |
| 124 | } |
| 125 | |
| 126 | // update the master branch |
| 127 | if !assert.NoError(t, g.ReplaceData(testutil.Dataset2)) { |
| 128 | return |
| 129 | } |
| 130 | |
| 131 | if !assert.NoError(t, g.Commit("new dataset")) { |
| 132 | return |
| 133 | } |
| 134 | |
| 135 | // update the cloned package |
| 136 | updateCmd := cmdupdate.NewRunner("kpt") |
| 137 | if !assert.NoError(t, os.Chdir(w.WorkspaceDirectory)) { |
| 138 | return |
| 139 | } |
| 140 | updateCmd.Command.SetArgs([]string{g.RepoName}) |
| 141 | err = updateCmd.Command.Execute() |
| 142 | if !assert.Error(t, err) { |
| 143 | return |
| 144 | } |
| 145 | assert.Contains(t, err.Error(), "must commit package") |
| 146 | |
| 147 | if !g.AssertEqual(t, filepath.Join(g.DatasetDirectory, testutil.Dataset1), dest) { |
| 148 | return |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | // NoOpRunE is a noop function to replace the run function of a command. Useful for testing argument parsing. |
| 153 | var NoOpRunE = func(cmd *cobra.Command, args []string) error { return nil } |
nothing calls this directly
no test coverage detected