TestCommand_Run_subdirAndDestination verifies that Command will copy a subdirectory of a repo to a specific destination. - name of the destination is used over the name of the subdir in the KptFile
(t *testing.T)
| 177 | // |
| 178 | // - name of the destination is used over the name of the subdir in the KptFile |
| 179 | func TestCommand_Run_subdirAndDestination(t *testing.T) { |
| 180 | subdir := "java" |
| 181 | dest := "new-java" |
| 182 | g, w, clean := testutil.SetupDefaultRepoAndWorkspace(t, testutil.Dataset1) |
| 183 | defer clean() |
| 184 | |
| 185 | err := Command{ |
| 186 | Git: kptfile.Git{Repo: g.RepoDirectory, Ref: "master", Directory: subdir}, |
| 187 | Destination: dest, |
| 188 | }.Run() |
| 189 | assert.NoError(t, err) |
| 190 | |
| 191 | // verify the cloned contents matches the repository |
| 192 | r := filepath.Join(w.WorkspaceDirectory, dest) |
| 193 | g.AssertEqual(t, filepath.Join(g.DatasetDirectory, testutil.Dataset1, subdir), r) |
| 194 | |
| 195 | // verify the KptFile contains the expected values |
| 196 | commit, err := g.GetCommit() |
| 197 | assert.NoError(t, err) |
| 198 | g.AssertKptfile(t, r, kptfile.KptFile{ |
| 199 | ResourceMeta: yaml.ResourceMeta{ |
| 200 | ObjectMeta: yaml.ObjectMeta{ |
| 201 | NameMeta: yaml.NameMeta{ |
| 202 | Name: dest, |
| 203 | }, |
| 204 | }, |
| 205 | TypeMeta: yaml.TypeMeta{ |
| 206 | APIVersion: kptfile.TypeMeta.APIVersion, |
| 207 | Kind: kptfile.TypeMeta.Kind}, |
| 208 | }, |
| 209 | PackageMeta: kptfile.PackageMeta{}, |
| 210 | Upstream: kptfile.Upstream{ |
| 211 | Type: "git", |
| 212 | Git: kptfile.Git{ |
| 213 | Commit: commit, |
| 214 | Directory: subdir, |
| 215 | Ref: "master", |
| 216 | Repo: g.RepoDirectory, |
| 217 | }, |
| 218 | }, |
| 219 | }) |
| 220 | } |
| 221 | |
| 222 | // TestCommand_Run_branch verifies Command can clone a git branch |
| 223 | // |
nothing calls this directly
no test coverage detected