MCPcopy Index your code
hub / github.com/appleboy/CodeGPT / TestGetAPIKeyFromHelper_EmptyOutput

Function TestGetAPIKeyFromHelper_EmptyOutput

util/api_key_helper_test.go:75–105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

73}
74
75func TestGetAPIKeyFromHelper_EmptyOutput(t *testing.T) {
76 tests := []struct {
77 name string
78 command string
79 }{
80 {
81 name: "true command with no output",
82 command: "true",
83 },
84 {
85 name: "command outputting only whitespace",
86 command: "echo ' '",
87 },
88 {
89 name: "command outputting only newlines",
90 command: "printf '\\n\\n'",
91 },
92 }
93
94 for _, tt := range tests {
95 t.Run(tt.name, func(t *testing.T) {
96 _, err := GetAPIKeyFromHelper(context.Background(), tt.command)
97 if err == nil {
98 t.Fatal("GetAPIKeyFromHelper() with empty output should return error")
99 }
100 if !strings.Contains(err.Error(), "empty output") {
101 t.Errorf("error message should mention empty output, got: %v", err)
102 }
103 })
104 }
105}
106
107func TestGetAPIKeyFromHelper_CommandFailure(t *testing.T) {
108 tests := []struct {

Callers

nothing calls this directly

Calls 1

GetAPIKeyFromHelperFunction · 0.70

Tested by

no test coverage detected