(t *testing.T)
| 168 | } |
| 169 | |
| 170 | func TestSecretSetClientOptions(t *testing.T) { |
| 171 | t.Run("defaults include timeout", func(t *testing.T) { |
| 172 | opts := secretSetClientOptions("") |
| 173 | if opts.Host != "" { |
| 174 | t.Fatalf("expected empty host, got %q", opts.Host) |
| 175 | } |
| 176 | if opts.Timeout != constants.DefaultHTTPClientTimeout { |
| 177 | t.Fatalf("expected timeout %s, got %s", constants.DefaultHTTPClientTimeout, opts.Timeout) |
| 178 | } |
| 179 | }) |
| 180 | |
| 181 | t.Run("normalizes host when api-url is provided", func(t *testing.T) { |
| 182 | opts := secretSetClientOptions("https://ghe.example.com") |
| 183 | if opts.Host != "ghe.example.com" { |
| 184 | t.Fatalf("expected host ghe.example.com, got %q", opts.Host) |
| 185 | } |
| 186 | if opts.Timeout != constants.DefaultHTTPClientTimeout { |
| 187 | t.Fatalf("expected timeout %s, got %s", constants.DefaultHTTPClientTimeout, opts.Timeout) |
| 188 | } |
| 189 | }) |
| 190 | |
| 191 | t.Run("strips API path from api-url", func(t *testing.T) { |
| 192 | opts := secretSetClientOptions("https://ghe.example.com/api/v3") |
| 193 | if opts.Host != "ghe.example.com" { |
| 194 | t.Fatalf("expected host ghe.example.com, got %q", opts.Host) |
| 195 | } |
| 196 | if opts.Timeout != constants.DefaultHTTPClientTimeout { |
| 197 | t.Fatalf("expected timeout %s, got %s", constants.DefaultHTTPClientTimeout, opts.Timeout) |
| 198 | } |
| 199 | }) |
| 200 | |
| 201 | t.Run("maps api.github.com to github.com", func(t *testing.T) { |
| 202 | opts := secretSetClientOptions("https://api.github.com") |
| 203 | if opts.Host != "github.com" { |
| 204 | t.Fatalf("expected host github.com, got %q", opts.Host) |
| 205 | } |
| 206 | if opts.Timeout != constants.DefaultHTTPClientTimeout { |
| 207 | t.Fatalf("expected timeout %s, got %s", constants.DefaultHTTPClientTimeout, opts.Timeout) |
| 208 | } |
| 209 | }) |
| 210 | } |
nothing calls this directly
no test coverage detected