(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestURLPlaceholders(t *testing.T) { |
| 16 | t.Run("returns nil for a URL with no placeholders", func(t *testing.T) { |
| 17 | assert.Nil(t, urlPlaceholders("https://api.example.com/v1")) |
| 18 | }) |
| 19 | |
| 20 | t.Run("extracts a single placeholder", func(t *testing.T) { |
| 21 | got := urlPlaceholders("https://{host}.example.com/v1") |
| 22 | assert.Len(t, got, 1) |
| 23 | assert.Contains(t, got, "host") |
| 24 | }) |
| 25 | |
| 26 | t.Run("extracts multiple placeholders and dedupes repeats", func(t *testing.T) { |
| 27 | got := urlPlaceholders("https://{host}.example.com:{port}/{base}/{host}") |
| 28 | assert.Len(t, got, 3) |
| 29 | assert.Contains(t, got, "host") |
| 30 | assert.Contains(t, got, "port") |
| 31 | assert.Contains(t, got, "base") |
| 32 | }) |
| 33 | |
| 34 | t.Run("does not span across `/`", func(t *testing.T) { |
| 35 | // "{a/b}" must not be treated as a single placeholder named "a/b". |
| 36 | assert.Nil(t, urlPlaceholders("https://{a/b}.example.com")) |
| 37 | }) |
| 38 | } |
| 39 | |
| 40 | func TestUsedAndUndeclaredVariables(t *testing.T) { |
| 41 | srv := ServerObjectDefinition{ |
nothing calls this directly
no test coverage detected