(t *testing.T)
| 22 | } |
| 23 | |
| 24 | func TestGetAPIKeyFromHelper_Success(t *testing.T) { |
| 25 | tests := []struct { |
| 26 | name string |
| 27 | command string |
| 28 | expected string |
| 29 | }{ |
| 30 | { |
| 31 | name: "simple echo command", |
| 32 | command: "echo 'test-api-key'", |
| 33 | expected: "test-api-key", |
| 34 | }, |
| 35 | { |
| 36 | name: "command with whitespace", |
| 37 | command: "echo ' test-key-with-spaces '", |
| 38 | expected: "test-key-with-spaces", |
| 39 | }, |
| 40 | { |
| 41 | name: "command with newlines", |
| 42 | command: "printf 'key-with-newline\\n'", |
| 43 | expected: "key-with-newline", |
| 44 | }, |
| 45 | { |
| 46 | name: "multi-word echo", |
| 47 | command: "echo sk-1234567890abcdef", |
| 48 | expected: "sk-1234567890abcdef", |
| 49 | }, |
| 50 | } |
| 51 | |
| 52 | for _, tt := range tests { |
| 53 | t.Run(tt.name, func(t *testing.T) { |
| 54 | result, err := GetAPIKeyFromHelper(context.Background(), tt.command) |
| 55 | if err != nil { |
| 56 | t.Fatalf("GetAPIKeyFromHelper() error = %v, want nil", err) |
| 57 | } |
| 58 | if result != tt.expected { |
| 59 | t.Errorf("GetAPIKeyFromHelper() = %q, want %q", result, tt.expected) |
| 60 | } |
| 61 | }) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | func TestGetAPIKeyFromHelper_EmptyCommand(t *testing.T) { |
| 66 | _, err := GetAPIKeyFromHelper(context.Background(), "") |
nothing calls this directly
no test coverage detected