|
6 | 6 | "strings" |
7 | 7 | "testing" |
8 | 8 |
|
| 9 | + "github.com/github/gh-aw/pkg/constants" |
9 | 10 | "github.com/stretchr/testify/assert" |
10 | 11 | "github.com/stretchr/testify/require" |
11 | 12 | ) |
@@ -758,3 +759,54 @@ func TestBuildStartCliProxyStepYAML(t *testing.T) { |
758 | 759 | assert.Contains(t, result, "start_cli_proxy.sh", "should reference the start script") |
759 | 760 | }) |
760 | 761 | } |
| 762 | + |
| 763 | +// TestResolveProxyContainerImage verifies that the helper builds the correct container |
| 764 | +// image reference from the gateway config, falling back to the default version when |
| 765 | +// no version is specified. |
| 766 | +func TestResolveProxyContainerImage(t *testing.T) { |
| 767 | + tests := []struct { |
| 768 | + name string |
| 769 | + config *MCPGatewayRuntimeConfig |
| 770 | + expected string |
| 771 | + }{ |
| 772 | + { |
| 773 | + name: "uses default version when version is empty", |
| 774 | + config: &MCPGatewayRuntimeConfig{ |
| 775 | + Container: constants.DefaultMCPGatewayContainer, |
| 776 | + Version: "", |
| 777 | + }, |
| 778 | + expected: constants.DefaultMCPGatewayContainer + ":" + string(constants.DefaultMCPGatewayVersion), |
| 779 | + }, |
| 780 | + { |
| 781 | + name: "uses explicit version when set", |
| 782 | + config: &MCPGatewayRuntimeConfig{ |
| 783 | + Container: constants.DefaultMCPGatewayContainer, |
| 784 | + Version: "v1.2.3", |
| 785 | + }, |
| 786 | + expected: constants.DefaultMCPGatewayContainer + ":v1.2.3", |
| 787 | + }, |
| 788 | + { |
| 789 | + name: "custom container with default version fallback", |
| 790 | + config: &MCPGatewayRuntimeConfig{ |
| 791 | + Container: "ghcr.io/myorg/my-proxy", |
| 792 | + Version: "", |
| 793 | + }, |
| 794 | + expected: "ghcr.io/myorg/my-proxy:" + string(constants.DefaultMCPGatewayVersion), |
| 795 | + }, |
| 796 | + { |
| 797 | + name: "custom container with explicit version", |
| 798 | + config: &MCPGatewayRuntimeConfig{ |
| 799 | + Container: "ghcr.io/myorg/my-proxy", |
| 800 | + Version: "latest", |
| 801 | + }, |
| 802 | + expected: "ghcr.io/myorg/my-proxy:latest", |
| 803 | + }, |
| 804 | + } |
| 805 | + |
| 806 | + for _, tt := range tests { |
| 807 | + t.Run(tt.name, func(t *testing.T) { |
| 808 | + got := resolveProxyContainerImage(tt.config) |
| 809 | + assert.Equal(t, tt.expected, got, "resolveProxyContainerImage(%+v)", tt.config) |
| 810 | + }) |
| 811 | + } |
| 812 | +} |
0 commit comments