MCPcopy Create free account
hub / github.com/dirk/quickhook / TestPromptForInstall

Function TestPromptForInstall

install_test.go:54–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func TestPromptForInstall(t *testing.T) {
55 ptyTests := []struct {
56 name string
57 stdin string
58 expected bool
59 }{
60 {
61 "yes",
62 "yes\n",
63 true,
64 },
65 {
66 "short yes",
67 "y\n",
68 true,
69 },
70 {
71 "no",
72 "no\n",
73 false,
74 },
75 {
76 "short no",
77 "n\n",
78 false,
79 },
80 {
81 "no input",
82 "",
83 false,
84 },
85 }
86 for _, tt := range ptyTests {
87 t.Run(tt.name, func(t *testing.T) {
88 tempDir := test.NewTempDir(t, 0)
89 repo := &repo.Repo{Root: tempDir.Root}
90
91 stdin := strings.NewReader(tt.stdin)
92 shouldInstall, err := promptForInstallShim(stdin, repo, ".git/hooks/pre-commit")
93 assert.NoError(t, err)
94 assert.Equal(t, tt.expected, shouldInstall)
95 })
96 }
97}

Callers

nothing calls this directly

Calls 3

NewTempDirFunction · 0.92
promptForInstallShimFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected