github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/deploy/component/kubernetes/debugger_test.go (about)

     1  /*
     2  Copyright 2021 The Skaffold 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 kubernetes
    18  
    19  import (
    20  	"reflect"
    21  	"testing"
    22  
    23  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
    24  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/debug"
    25  	"github.com/GoogleContainerTools/skaffold/testutil"
    26  )
    27  
    28  func TestGetDebugger(t *testing.T) {
    29  	tests := []struct {
    30  		description string
    31  		runMode     config.RunMode
    32  		isNoop      bool
    33  	}{
    34  		{
    35  			description: "unspecified run mode defaults to disabled",
    36  			isNoop:      true,
    37  		},
    38  		{
    39  			description: "run mode set to debug",
    40  			runMode:     config.RunModes.Debug,
    41  		},
    42  		{
    43  			description: "run mode set to dev",
    44  			runMode:     config.RunModes.Dev,
    45  			isNoop:      true,
    46  		},
    47  	}
    48  
    49  	for _, test := range tests {
    50  		testutil.Run(t, test.description, func(t *testutil.T) {
    51  			d := NewDebugger(test.runMode, nil, nil, "")
    52  			t.CheckDeepEqual(test.isNoop, reflect.Indirect(reflect.ValueOf(d)).Type() == reflect.TypeOf(debug.NoopDebugger{}))
    53  		})
    54  	}
    55  }