(t *testing.T)
| 73 | } |
| 74 | |
| 75 | func 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 | |
| 107 | func TestGetAPIKeyFromHelper_CommandFailure(t *testing.T) { |
| 108 | tests := []struct { |
nothing calls this directly
no test coverage detected