vitess.io/vitess@v0.16.2/go/vt/vttest/environment_test.go (about)

     1  /*
     2  Copyright 2021 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  	http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package vttest
    18  
    19  import (
    20  	"sort"
    21  	"strings"
    22  	"testing"
    23  
    24  	"github.com/stretchr/testify/assert"
    25  	"github.com/stretchr/testify/require"
    26  )
    27  
    28  func TestVtcomboArguments(t *testing.T) {
    29  	env := &LocalTestEnv{}
    30  	args := env.VtcomboArguments()
    31  
    32  	t.Run("service_map flag", func(t *testing.T) {
    33  		require.Contains(t, args, "--service_map", "vttest.LocalTestEnv must provide `--service_map` flag to vtcombo")
    34  
    35  		x := sort.SearchStrings(args, "--service_map")
    36  		require.Less(t, x+1, len(args), "--service_map vtcombo flag (idx = %d) must take an argument. full arg list: %v", x, args)
    37  
    38  		expectedServiceList := []string{
    39  			"grpc-vtgateservice",
    40  			"grpc-vtctl",
    41  			"grpc-vtctld",
    42  		}
    43  		serviceMapList := strings.Split(args[x+1], ",")
    44  		assert.ElementsMatch(t, expectedServiceList, serviceMapList, "--service_map list does not contain expected vtcombo services")
    45  	})
    46  }