TestCmd verifies the directory is initialized
(t *testing.T)
| 30 | |
| 31 | // TestCmd verifies the directory is initialized |
| 32 | func TestCmd(t *testing.T) { |
| 33 | d, err := ioutil.TempDir("", "kpt") |
| 34 | assert.NoError(t, err) |
| 35 | assert.NoError(t, os.Mkdir(filepath.Join(d, "my-pkg"), 0700)) |
| 36 | |
| 37 | r := cmdinit.NewRunner("kpt") |
| 38 | r.Command.SetArgs([]string{filepath.Join(d, "my-pkg"), "--description", "my description", "--tag", "app.kpt.dev/cockroachdb"}) |
| 39 | err = r.Command.Execute() |
| 40 | assert.NoError(t, err) |
| 41 | |
| 42 | // verify the contents |
| 43 | b, err := ioutil.ReadFile(filepath.Join(d, "my-pkg", "Kptfile")) |
| 44 | assert.NoError(t, err) |
| 45 | assert.Equal(t, `apiVersion: kpt.dev/v1alpha1 |
| 46 | kind: Kptfile |
| 47 | metadata: |
| 48 | name: my-pkg |
| 49 | packageMetadata: |
| 50 | tags: |
| 51 | - app.kpt.dev/cockroachdb |
| 52 | shortDescription: my description |
| 53 | `, string(b)) |
| 54 | |
| 55 | b, err = ioutil.ReadFile(filepath.Join(d, "my-pkg", man.ManFilename)) |
| 56 | assert.NoError(t, err) |
| 57 | assert.Equal(t, strings.ReplaceAll(`# my-pkg |
| 58 | |
| 59 | ## Description |
| 60 | my description |
| 61 | |
| 62 | ## Usage |
| 63 | |
| 64 | ### Fetch the package |
| 65 | 'kpt pkg get REPO_URI[.git]/PKG_PATH[@VERSION] my-pkg' |
| 66 | Details: https://googlecontainertools.github.io/kpt/reference/pkg/get/ |
| 67 | |
| 68 | ### View package content |
| 69 | 'kpt cfg tree my-pkg' |
| 70 | Details: https://googlecontainertools.github.io/kpt/reference/cfg/tree/ |
| 71 | |
| 72 | ### List setters |
| 73 | 'kpt cfg list-setters my-pkg' |
| 74 | Details: https://googlecontainertools.github.io/kpt/reference/cfg/list-setters/ |
| 75 | |
| 76 | ### Set a value |
| 77 | 'kpt cfg set my-pkg NAME VALUE' |
| 78 | Details: https://googlecontainertools.github.io/kpt/reference/cfg/set/ |
| 79 | |
| 80 | ### Apply the package |
| 81 | ''' |
| 82 | kpt live init my-pkg |
| 83 | kpt live apply my-pkg --reconcile-timeout=2m --output=table |
| 84 | ''' |
| 85 | Details: https://googlecontainertools.github.io/kpt/reference/live/ |
| 86 | `, "'", "`"), string(b)) |
| 87 | } |
| 88 | |
| 89 | func TestCmd_currentDir(t *testing.T) { |
nothing calls this directly
no test coverage detected