|
| 1 | +// © 2025 Platform Engineering Labs Inc. |
| 2 | +// |
| 3 | +// SPDX-License-Identifier: FSL-1.1-ALv2 |
| 4 | + |
| 5 | +package api |
| 6 | + |
| 7 | +import ( |
| 8 | + "testing" |
| 9 | + |
| 10 | + "github.com/stretchr/testify/assert" |
| 11 | +) |
| 12 | + |
| 13 | +func TestFormatEndpointStandardPort(t *testing.T) { |
| 14 | + want := "http://localhost:49684" |
| 15 | + got := formatEndpoint("http://localhost", 49684) |
| 16 | + |
| 17 | + assert.Equal(t, want, got) |
| 18 | +} |
| 19 | + |
| 20 | +func TestFormatEndpointHTTPSDefault(t *testing.T) { |
| 21 | + want := "https://example.awsapprunner.com" |
| 22 | + got := formatEndpoint("https://example.awsapprunner.com", 443) |
| 23 | + |
| 24 | + assert.Equal(t, want, got) |
| 25 | +} |
| 26 | + |
| 27 | +func TestFormatEndpointHTTPDefault(t *testing.T) { |
| 28 | + want := "http://example.com" |
| 29 | + got := formatEndpoint("http://example.com", 80) |
| 30 | + |
| 31 | + assert.Equal(t, want, got) |
| 32 | +} |
| 33 | + |
| 34 | +func TestFormatEndpointHTTPSNonDefault(t *testing.T) { |
| 35 | + want := "https://example.com:8443" |
| 36 | + got := formatEndpoint("https://example.com", 8443) |
| 37 | + |
| 38 | + assert.Equal(t, want, got) |
| 39 | +} |
| 40 | + |
| 41 | +func TestFormatEndpointHTTPWith443(t *testing.T) { |
| 42 | + want := "http://example.com:443" |
| 43 | + got := formatEndpoint("http://example.com", 443) |
| 44 | + |
| 45 | + assert.Equal(t, want, got) |
| 46 | +} |
| 47 | + |
| 48 | +func TestFormatEndpointHTTPSWith80(t *testing.T) { |
| 49 | + want := "https://example.com:80" |
| 50 | + got := formatEndpoint("https://example.com", 80) |
| 51 | + |
| 52 | + assert.Equal(t, want, got) |
| 53 | +} |
0 commit comments