MCPcopy Create free account
hub / github.com/alibaba/open-code-review / TestCompleteSessionIDs

Function TestCompleteSessionIDs

cmd/opencodereview/misc_helpers_test.go:67–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestCompleteSessionIDs(t *testing.T) {
68 t.Run("with args returns no completions", func(t *testing.T) {
69 cmd := &cobra.Command{Use: "x"}
70 comps, directive := completeSessionIDs(cmd, []string{"already"}, "")
71 if comps != nil {
72 t.Errorf("expected nil completions, got %v", comps)
73 }
74 if directive != cobra.ShellCompDirectiveNoFileComp {
75 t.Errorf("directive = %v, want NoFileComp", directive)
76 }
77 })
78
79 t.Run("fresh repo yields empty completions", func(t *testing.T) {
80 dir := initTestGitRepo(t)
81 cmd := &cobra.Command{Use: "x"}
82 cmd.Flags().String("repo", dir, "")
83 comps, directive := completeSessionIDs(cmd, nil, "")
84 if len(comps) != 0 {
85 t.Errorf("expected no completions for fresh repo, got %v", comps)
86 }
87 if directive != cobra.ShellCompDirectiveNoFileComp {
88 t.Errorf("directive = %v, want NoFileComp", directive)
89 }
90 })
91}

Callers

nothing calls this directly

Calls 4

completeSessionIDsFunction · 0.85
initTestGitRepoFunction · 0.85
RunMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected