(t *testing.T)
| 1563 | } |
| 1564 | |
| 1565 | func TestResolveTestTarget(t *testing.T) { |
| 1566 | logger := zap.NewNop() |
| 1567 | |
| 1568 | tests := []struct { |
| 1569 | name string |
| 1570 | originalTarget string |
| 1571 | urlReplacements map[string]string |
| 1572 | portMappings map[uint32]uint32 |
| 1573 | configHost string |
| 1574 | appPort uint16 |
| 1575 | configPort uint32 |
| 1576 | isHTTP bool |
| 1577 | expectedTarget string |
| 1578 | expectError bool |
| 1579 | }{ |
| 1580 | // HTTP Scenarios |
| 1581 | { |
| 1582 | name: "HTTP_NoOverrides", |
| 1583 | originalTarget: "http://example.com/api", |
| 1584 | isHTTP: true, |
| 1585 | expectedTarget: "http://example.com:80/api", |
| 1586 | }, |
| 1587 | { |
| 1588 | name: "HTTP_AppPortOverride", |
| 1589 | originalTarget: "http://example.com/api", |
| 1590 | appPort: 8080, |
| 1591 | isHTTP: true, |
| 1592 | expectedTarget: "http://example.com:8080/api", |
| 1593 | }, |
| 1594 | { |
| 1595 | name: "HTTP_ConfigPortOverride", |
| 1596 | originalTarget: "http://example.com/api", |
| 1597 | appPort: 8080, |
| 1598 | configPort: 9090, |
| 1599 | isHTTP: true, |
| 1600 | expectedTarget: "http://example.com:9090/api", |
| 1601 | }, |
| 1602 | { |
| 1603 | name: "HTTP_ConfigHostOverride", |
| 1604 | originalTarget: "http://example.com/api", |
| 1605 | configHost: "localhost", |
| 1606 | isHTTP: true, |
| 1607 | expectedTarget: "http://localhost:80/api", |
| 1608 | }, |
| 1609 | { |
| 1610 | name: "HTTP_ReplacementWithPort_Final", |
| 1611 | originalTarget: "http://example.com/api", |
| 1612 | urlReplacements: map[string]string{"example.com": "localhost:3000"}, |
| 1613 | configPort: 9090, // Should be ignored |
| 1614 | isHTTP: true, |
| 1615 | expectedTarget: "http://localhost:3000/api", |
| 1616 | }, |
| 1617 | { |
| 1618 | name: "HTTP_ReplacementWithoutPort_AppliesOverrides", |
| 1619 | originalTarget: "http://example.com/api", |
| 1620 | urlReplacements: map[string]string{"example.com": "new-host"}, |
| 1621 | configPort: 9090, |
| 1622 | isHTTP: true, |
nothing calls this directly
no test coverage detected