mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
remove unnecessary unit tests (#3856)
This commit is contained in:
@@ -5,12 +5,9 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/openshift/odo/pkg/testingutil/filesystem"
|
||||
|
||||
"github.com/openshift/odo/pkg/util"
|
||||
)
|
||||
|
||||
func TestSetLocalConfiguration(t *testing.T) {
|
||||
@@ -279,16 +276,6 @@ func TestLocalUnsetConfiguration(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLowerCaseParameterForLocalParameters(t *testing.T) {
|
||||
expected := map[string]bool{"name": true, "minmemory": true, "ignore": true, "project": true,
|
||||
"application": true, "type": true, "ref": true, "mincpu": true, "cpu": true, "ports": true, "maxmemory": true,
|
||||
"maxcpu": true, "sourcetype": true, "sourcelocation": true, "memory": true, "storage": true, "url": true, "debugport": true}
|
||||
actual := util.GetLowerCaseParameters(GetLocallySupportedParameters())
|
||||
if !reflect.DeepEqual(expected, actual) {
|
||||
t.Errorf("expected '%v', got '%v'", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalConfigInitDoesntCreateLocalOdoFolder(t *testing.T) {
|
||||
// cleaning up old odo files if any
|
||||
filename, err := getLocalConfigFile("")
|
||||
@@ -531,18 +518,3 @@ func createDirectoryAndFile(create bool, fs filesystem.Filesystem, odoDir string
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func mockLocalConfigInfo(configDir string, fs filesystem.Filesystem) (*LocalConfigInfo, error) {
|
||||
|
||||
lci := &LocalConfigInfo{
|
||||
Filename: filepath.Join(configDir, ".odo", "config.yaml"),
|
||||
fs: fs,
|
||||
}
|
||||
err := fs.MkdirAll(filepath.Join(configDir, ".odo"), os.ModePerm)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return lci, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/openshift/odo/pkg/testingutil/filesystem"
|
||||
)
|
||||
|
||||
func GetOneExistingConfigInfo(componentName, applicationName, projectName string) LocalConfigInfo {
|
||||
componentType := "nodejs"
|
||||
sourceLocation := "./"
|
||||
@@ -97,3 +104,18 @@ func GetOneNonExistingConfigInfo() LocalConfigInfo {
|
||||
LocalConfig: LocalConfig{},
|
||||
}
|
||||
}
|
||||
|
||||
func mockLocalConfigInfo(configDir string, fs filesystem.Filesystem) (*LocalConfigInfo, error) {
|
||||
|
||||
lci := &LocalConfigInfo{
|
||||
Filename: filepath.Join(configDir, ".odo", "config.yaml"),
|
||||
fs: fs,
|
||||
}
|
||||
err := fs.MkdirAll(filepath.Join(configDir, ".odo"), os.ModePerm)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return lci, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/openshift/odo/pkg/testingutil/filesystem"
|
||||
|
||||
"github.com/openshift/odo/pkg/util"
|
||||
)
|
||||
|
||||
func TestSetEnvInfo(t *testing.T) {
|
||||
@@ -365,14 +363,6 @@ func TestGetPushCommand(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestLowerCaseParameterForLocalParameters(t *testing.T) {
|
||||
expected := map[string]bool{"debugport": true, "name": true, "namespace": true, "push": true, "url": true, "link": true}
|
||||
actual := util.GetLowerCaseParameters(GetLocallySupportedParameters())
|
||||
if !reflect.DeepEqual(expected, actual) {
|
||||
t.Errorf("expected '%v', got '%v'", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnvSpecificInfonitDoesntCreateLocalOdoFolder(t *testing.T) {
|
||||
// cleaning up old odo files if any
|
||||
filename, err := getEnvInfoFile("")
|
||||
|
||||
37
pkg/odo/cli/env/env_test.go
vendored
37
pkg/odo/cli/env/env_test.go
vendored
@@ -59,40 +59,3 @@ func TestPrintSupportedParameters(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsSupportedParameter(t *testing.T) {
|
||||
supportedSetParameters := map[string]string{
|
||||
nameParameter: nameParameterDescription,
|
||||
namespaceParameter: namespaceParameterDescription,
|
||||
debugportParameter: debugportParameterDescription,
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
parameter string
|
||||
supportedParameters map[string]string
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "Case 1: Test supported parameter",
|
||||
parameter: "Name",
|
||||
supportedParameters: supportedSetParameters,
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "Case 2: Test unsupported parameter",
|
||||
parameter: "Fake",
|
||||
supportedParameters: supportedSetParameters,
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := isSupportedParameter(tt.parameter, tt.supportedParameters)
|
||||
if got != tt.want {
|
||||
t.Errorf("Got %t, want %t", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import (
|
||||
"reflect"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/openshift/odo/pkg/util"
|
||||
)
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
@@ -701,51 +699,6 @@ func TestGetPushTarget(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatSupportedParameters(t *testing.T) {
|
||||
expected := `
|
||||
Available Global Parameters:
|
||||
%s - %s
|
||||
%s - %s
|
||||
%s - %s
|
||||
%s - %s
|
||||
%s - %s
|
||||
%s - %s
|
||||
%s - %s
|
||||
%s - %s
|
||||
`
|
||||
expected = fmt.Sprintf(expected,
|
||||
BuildTimeoutSetting, BuildTimeoutSettingDescription,
|
||||
ExperimentalSetting, ExperimentalDescription,
|
||||
NamePrefixSetting, NamePrefixSettingDescription,
|
||||
PushTargetSetting, PushTargetDescription,
|
||||
PushTimeoutSetting, PushTimeoutSettingDescription,
|
||||
RegistryCacheTimeSetting, RegistryCacheTimeDescription,
|
||||
TimeoutSetting, TimeoutSettingDescription,
|
||||
UpdateNotificationSetting, UpdateNotificationSettingDescription,
|
||||
)
|
||||
actual := FormatSupportedParameters()
|
||||
if expected != actual {
|
||||
t.Errorf("expected '%s', got '%s'", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLowerCaseParameters(t *testing.T) {
|
||||
expected := map[string]bool{
|
||||
"nameprefix": true,
|
||||
"buildtimeout": true,
|
||||
"pushtimeout": true,
|
||||
"registrycachetime": true,
|
||||
"timeout": true,
|
||||
"updatenotification": true,
|
||||
"experimental": true,
|
||||
"pushtarget": true,
|
||||
}
|
||||
actual := util.GetLowerCaseParameters(GetSupportedParameters())
|
||||
if !reflect.DeepEqual(expected, actual) {
|
||||
t.Errorf("expected '%v', got '%v'", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsSupportedParameter(t *testing.T) {
|
||||
tests := []struct {
|
||||
testName string
|
||||
|
||||
Reference in New Issue
Block a user