(t *testing.T)
| 222 | } |
| 223 | |
| 224 | func TestFormatRemoteURL(t *testing.T) { |
| 225 | tests := []struct { |
| 226 | name string |
| 227 | repoHost string |
| 228 | repoOwner string |
| 229 | repoName string |
| 230 | protocol string |
| 231 | want string |
| 232 | }{ |
| 233 | { |
| 234 | name: "https protocol", |
| 235 | repoHost: "github.com", |
| 236 | repoOwner: "owner", |
| 237 | repoName: "name", |
| 238 | protocol: "https", |
| 239 | want: "https://github.com/owner/name.git", |
| 240 | }, |
| 241 | { |
| 242 | name: "https protocol local host", |
| 243 | repoHost: "github.localhost", |
| 244 | repoOwner: "owner", |
| 245 | repoName: "name", |
| 246 | protocol: "https", |
| 247 | want: "http://github.localhost/owner/name.git", |
| 248 | }, |
| 249 | { |
| 250 | name: "ssh protocol", |
| 251 | repoHost: "github.com", |
| 252 | repoOwner: "owner", |
| 253 | repoName: "name", |
| 254 | protocol: "ssh", |
| 255 | want: "git@github.com:owner/name.git", |
| 256 | }, |
| 257 | { |
| 258 | name: "ssh protocol tenancy host", |
| 259 | repoHost: "tenant.ghe.com", |
| 260 | repoOwner: "owner", |
| 261 | repoName: "name", |
| 262 | protocol: "ssh", |
| 263 | want: "tenant@tenant.ghe.com:owner/name.git", |
| 264 | }, |
| 265 | } |
| 266 | for _, tt := range tests { |
| 267 | t.Run(tt.name, func(t *testing.T) { |
| 268 | r := ghRepo{ |
| 269 | hostname: tt.repoHost, |
| 270 | owner: tt.repoOwner, |
| 271 | name: tt.repoName, |
| 272 | } |
| 273 | if url := FormatRemoteURL(r, tt.protocol); url != tt.want { |
| 274 | t.Errorf("expected url %q, got %q", tt.want, url) |
| 275 | } |
| 276 | }) |
| 277 | } |
| 278 | } |
nothing calls this directly
no test coverage detected