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

Function TestCmd

internal/cmdinit/cmdinit_test.go:32–87  ·  view source on GitHub ↗

TestCmd verifies the directory is initialized

(t *testing.T)

Source from the content-addressed store, hash-verified

30
31// TestCmd verifies the directory is initialized
32func 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
46kind: Kptfile
47metadata:
48 name: my-pkg
49packageMetadata:
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
60my description
61
62## Usage
63
64### Fetch the package
65'kpt pkg get REPO_URI[.git]/PKG_PATH[@VERSION] my-pkg'
66Details: https://googlecontainertools.github.io/kpt/reference/pkg/get/
67
68### View package content
69'kpt cfg tree my-pkg'
70Details: https://googlecontainertools.github.io/kpt/reference/cfg/tree/
71
72### List setters
73'kpt cfg list-setters my-pkg'
74Details: https://googlecontainertools.github.io/kpt/reference/cfg/list-setters/
75
76### Set a value
77'kpt cfg set my-pkg NAME VALUE'
78Details: https://googlecontainertools.github.io/kpt/reference/cfg/set/
79
80### Apply the package
81'''
82kpt live init my-pkg
83kpt live apply my-pkg --reconcile-timeout=2m --output=table
84'''
85Details: https://googlecontainertools.github.io/kpt/reference/live/
86`, "'", "`"), string(b))
87}
88
89func TestCmd_currentDir(t *testing.T) {

Callers

nothing calls this directly

Calls 1

NewRunnerFunction · 0.92

Tested by

no test coverage detected