...

Source file src/k8s.io/kubernetes/test/e2e/storage/external/external_test.go

Documentation: k8s.io/kubernetes/test/e2e/storage/external

     1  /*
     2  Copyright 2019 The Kubernetes 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 external
    18  
    19  import (
    20  	"testing"
    21  
    22  	"github.com/stretchr/testify/assert"
    23  
    24  	"k8s.io/apimachinery/pkg/util/sets"
    25  	e2evolume "k8s.io/kubernetes/test/e2e/framework/volume"
    26  	storageframework "k8s.io/kubernetes/test/e2e/storage/framework"
    27  )
    28  
    29  func TestDriverParameter(t *testing.T) {
    30  	expected := &driverDefinition{
    31  		DriverInfo: storageframework.DriverInfo{
    32  			Name: "foo.example.com",
    33  			SupportedFsType: sets.NewString(
    34  				"", // Default fsType
    35  			),
    36  			SupportedSizeRange: e2evolume.SizeRange{
    37  				Min: "10Gi",
    38  			},
    39  		},
    40  	}
    41  	testcases := []struct {
    42  		name     string
    43  		filename string
    44  		err      string
    45  		expected *driverDefinition
    46  	}{
    47  		{
    48  			name:     "no such file",
    49  			filename: "no-such-file.yaml",
    50  			err:      "open no-such-file.yaml: no such file or directory",
    51  		},
    52  		{
    53  			name: "empty file name",
    54  			err:  "missing file name",
    55  		},
    56  		{
    57  			name:     "yaml",
    58  			filename: "testdata/driver.yaml",
    59  			expected: expected,
    60  		},
    61  		{
    62  			name:     "json",
    63  			filename: "testdata/driver.json",
    64  			expected: expected,
    65  		},
    66  	}
    67  
    68  	for _, testcase := range testcases {
    69  		actual, err := loadDriverDefinition(testcase.filename)
    70  		if testcase.err == "" {
    71  			assert.NoError(t, err, testcase.name)
    72  		} else {
    73  			if assert.Error(t, err, testcase.name) {
    74  				assert.Equal(t, testcase.err, err.Error())
    75  			}
    76  		}
    77  		if err == nil {
    78  			assert.Equal(t, testcase.expected, actual)
    79  		}
    80  	}
    81  }
    82  

View as plain text