Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 7 additions & 39 deletions command/connect/envoy/envoy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ import (

var update = flag.Bool("update", false, "update golden files")

const defaultOSPlatform = "linux"

func TestEnvoyCommand_noTabs(t *testing.T) {
t.Parallel()
if strings.ContainsRune(New(nil, defaultOSPlatform).Help(), '\t') {
if strings.ContainsRune(New(nil).Help(), '\t') {
t.Fatal("help has tabs")
}
}
Expand Down Expand Up @@ -67,8 +65,8 @@ func TestEnvoyGateway_Validation(t *testing.T) {
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
ui := cli.NewMockUi()
c := New(ui, defaultOSPlatform)
c.init(defaultOSPlatform)
c := New(ui)
c.init()

code := c.Run(tc.args)
if code == 0 {
Expand Down Expand Up @@ -123,7 +121,6 @@ type generateConfigTestCase struct {
AgentSelf110 bool // fake the agent API from versions v1.10 and earlier
WantArgs BootstrapTplArgs
WantErr string
OSPlatform string
}

// This tests the args we use to generate the template directly because they
Expand Down Expand Up @@ -164,28 +161,6 @@ func TestGenerateConfig(t *testing.T) {
PrometheusScrapePath: "/metrics",
},
},
{
Name: "defaults-windows",
Flags: []string{"-proxy-id", "test-proxy"},
WantArgs: BootstrapTplArgs{
ProxyCluster: "test-proxy",
ProxyID: "test-proxy",
// We don't know this til after the lookup so it will be empty in the
// initial args call we are testing here.
ProxySourceService: "",
GRPC: GRPC{
AgentAddress: "127.0.0.1",
AgentPort: "8502", // Note this is the gRPC port
},
AdminAccessLogPath: "nul",
AdminBindAddress: "127.0.0.1",
AdminBindPort: "19000",
LocalAgentClusterName: xds.LocalAgentClusterName,
PrometheusBackendPort: "",
PrometheusScrapePath: "/metrics",
},
OSPlatform: "windows",
},
{
Name: "defaults-nodemeta",
Flags: []string{"-proxy-id", "test-proxy", "-node-name", "test-node"},
Expand Down Expand Up @@ -1044,14 +1019,8 @@ func TestGenerateConfig(t *testing.T) {
client, err := api.NewClient(&api.Config{Address: srv.URL, TLSConfig: api.TLSConfig{InsecureSkipVerify: true}})
require.NoError(t, err)

// Default OS Platform "linux". Custom value should be set in the test case
osPlatform := "linux"
if tc.OSPlatform == "windows" {
osPlatform = tc.OSPlatform
}

ui := cli.NewMockUi()
c := New(ui, osPlatform)
c := New(ui)
// explicitly set the client to one which can connect to the httptest.Server
c.client = client

Expand All @@ -1060,7 +1029,7 @@ func TestGenerateConfig(t *testing.T) {
args := append([]string{"-bootstrap"}, myFlags...)

require.NoError(t, c.flags.Parse(args))
code := c.run(c.flags.Args(), osPlatform)
code := c.run(c.flags.Args())
if tc.WantErr == "" {
require.Equal(t, 0, code, ui.ErrorWriter.String())
} else {
Expand All @@ -1071,8 +1040,7 @@ func TestGenerateConfig(t *testing.T) {

// Verify we handled the env and flags right first to get correct template
// args.
got, err := c.templateArgs(osPlatform)

got, err := c.templateArgs()
require.NoError(t, err) // Error cases should have returned above
require.Equal(t, &tc.WantArgs, got)

Expand Down Expand Up @@ -1165,7 +1133,7 @@ func TestEnvoy_GatewayRegistration(t *testing.T) {
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
ui := cli.NewMockUi()
c := New(ui, defaultOSPlatform)
c := New(ui)

code := c.Run(tc.args)
if code != 0 {
Expand Down
210 changes: 0 additions & 210 deletions command/connect/envoy/testdata/defaults-windows.golden

This file was deleted.