Isolate unit tests by using temp directories

This commit changes several unit tests to set a "workspace" in a temp
directory. This completely isolates them from other tests as well as the
developer's environment.

Change-Id: Ifa1048c427dc3d69e15dae04318c7d8463b8f8e1
This commit is contained in:
Ian Howell 2019-11-12 14:13:55 -06:00
parent e48b436680
commit 61eecca7f3
9 changed files with 129 additions and 234 deletions

View File

@ -18,6 +18,7 @@ package config
import ( import (
"bytes" "bytes"
"path/filepath"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -34,11 +35,6 @@ type getClusterTest struct {
expected string expected string
} }
const (
testMimeType = ".yaml"
testDataDir = "../../pkg/config/testdata"
)
func TestGetCluster(t *testing.T) { func TestGetCluster(t *testing.T) {
tname := "def" tname := "def"
tctype := config.Ephemeral tctype := config.Ephemeral
@ -69,12 +65,15 @@ func TestGetCluster(t *testing.T) {
func TestGetAllClusters(t *testing.T) { func TestGetAllClusters(t *testing.T) {
conf := config.InitConfig(t) conf := config.InitConfig(t)
testDir := filepath.Dir(conf.LoadedConfigPath())
kubeconfigPath := filepath.Join(testDir, "kubeconfig")
expected := `Cluster: def expected := `Cluster: def
ephemeral: ephemeral:
bootstrap-info: "" bootstrap-info: ""
cluster-kubeconf: def_ephemeral cluster-kubeconf: def_ephemeral
LocationOfOrigin: ../../pkg/config/testdata/kubeconfig.yaml LocationOfOrigin: ` + kubeconfigPath + `
insecure-skip-tls-verify: true insecure-skip-tls-verify: true
server: http://5.6.7.8 server: http://5.6.7.8
@ -83,7 +82,7 @@ target:
bootstrap-info: "" bootstrap-info: ""
cluster-kubeconf: def_target cluster-kubeconf: def_target
LocationOfOrigin: ../../pkg/config/testdata/kubeconfig.yaml LocationOfOrigin: ` + kubeconfigPath + `
insecure-skip-tls-verify: true insecure-skip-tls-verify: true
server: http://1.2.3.4 server: http://1.2.3.4
@ -92,7 +91,7 @@ target:
bootstrap-info: "" bootstrap-info: ""
cluster-kubeconf: onlyinkubeconf_target cluster-kubeconf: onlyinkubeconf_target
LocationOfOrigin: ../../pkg/config/testdata/kubeconfig.yaml LocationOfOrigin: ` + kubeconfigPath + `
insecure-skip-tls-verify: true insecure-skip-tls-verify: true
server: http://9.10.11.12 server: http://9.10.11.12
@ -101,7 +100,7 @@ target:
bootstrap-info: "" bootstrap-info: ""
cluster-kubeconf: wrongonlyinkubeconf_target cluster-kubeconf: wrongonlyinkubeconf_target
LocationOfOrigin: ../../pkg/config/testdata/kubeconfig.yaml LocationOfOrigin: ` + kubeconfigPath + `
certificate-authority: cert_file certificate-authority: cert_file
server: "" server: ""

View File

@ -44,13 +44,13 @@ const (
) )
func TestSetClusterWithCAFile(t *testing.T) { func TestSetClusterWithCAFile(t *testing.T) {
conf := config.DefaultInitConfig(t) conf := config.InitConfig(t)
certFile := "../../pkg/config/testdata/ca.crt" certFile := "../../pkg/config/testdata/ca.crt"
tname := testCluster tname := testCluster
tctype := config.Ephemeral tctype := config.Ephemeral
expconf := config.DefaultInitConfig(t) expconf := config.InitConfig(t)
expconf.Clusters[tname] = config.NewClusterPurpose() expconf.Clusters[tname] = config.NewClusterPurpose()
expconf.Clusters[tname].ClusterTypes[tctype] = config.NewCluster() expconf.Clusters[tname].ClusterTypes[tctype] = config.NewCluster()
clusterName := config.NewClusterComplexName() clusterName := config.NewClusterComplexName()
@ -78,13 +78,13 @@ func TestSetClusterWithCAFile(t *testing.T) {
test.run(t) test.run(t)
} }
func TestSetClusterWithCAFileData(t *testing.T) { func TestSetClusterWithCAFileData(t *testing.T) {
conf := config.DefaultInitConfig(t) conf := config.InitConfig(t)
certFile := "../../pkg/config/testdata/ca.crt" certFile := "../../pkg/config/testdata/ca.crt"
tname := testCluster tname := testCluster
tctype := config.Ephemeral tctype := config.Ephemeral
expconf := config.DefaultInitConfig(t) expconf := config.InitConfig(t)
expconf.Clusters[tname] = config.NewClusterPurpose() expconf.Clusters[tname] = config.NewClusterPurpose()
expconf.Clusters[tname].ClusterTypes[tctype] = config.NewCluster() expconf.Clusters[tname].ClusterTypes[tctype] = config.NewCluster()
clusterName := config.NewClusterComplexName() clusterName := config.NewClusterComplexName()
@ -117,7 +117,7 @@ func TestSetClusterWithCAFileData(t *testing.T) {
func TestSetCluster(t *testing.T) { func TestSetCluster(t *testing.T) {
conf := config.DefaultInitConfig(t) conf := config.InitConfig(t)
// err := conf.Purge() // err := conf.Purge()
// assert.Nilf(t, err, "Unable to purge test configuration %v", err) // assert.Nilf(t, err, "Unable to purge test configuration %v", err)
@ -125,7 +125,7 @@ func TestSetCluster(t *testing.T) {
tname := testCluster tname := testCluster
tctype := config.Ephemeral tctype := config.Ephemeral
expconf := config.DefaultInitConfig(t) expconf := config.InitConfig(t)
expconf.Clusters[tname] = config.NewClusterPurpose() expconf.Clusters[tname] = config.NewClusterPurpose()
expconf.Clusters[tname].ClusterTypes[tctype] = config.NewCluster() expconf.Clusters[tname].ClusterTypes[tctype] = config.NewCluster()
clusterName := config.NewClusterComplexName() clusterName := config.NewClusterComplexName()
@ -156,7 +156,7 @@ func TestModifyCluster(t *testing.T) {
tname := testClusterName tname := testClusterName
tctype := config.Ephemeral tctype := config.Ephemeral
conf := config.DefaultInitConfig(t) conf := config.InitConfig(t)
conf.Clusters[tname] = config.NewClusterPurpose() conf.Clusters[tname] = config.NewClusterPurpose()
clusterName := config.NewClusterComplexName() clusterName := config.NewClusterComplexName()
clusterName.WithType(tname, tctype) clusterName.WithType(tname, tctype)
@ -167,7 +167,7 @@ func TestModifyCluster(t *testing.T) {
conf.KubeConfig().Clusters[clusterName.Name()] = kCluster conf.KubeConfig().Clusters[clusterName.Name()] = kCluster
conf.Clusters[tname].ClusterTypes[tctype].SetKubeCluster(kCluster) conf.Clusters[tname].ClusterTypes[tctype].SetKubeCluster(kCluster)
expconf := config.DefaultInitConfig(t) expconf := config.InitConfig(t)
expconf.Clusters[tname] = config.NewClusterPurpose() expconf.Clusters[tname] = config.NewClusterPurpose()
expconf.Clusters[tname].ClusterTypes[tctype] = config.NewCluster() expconf.Clusters[tname].ClusterTypes[tctype] = config.NewCluster()
expconf.Clusters[tname].ClusterTypes[tctype].NameInKubeconf = clusterName.Name() expconf.Clusters[tname].ClusterTypes[tctype].NameInKubeconf = clusterName.Name()
@ -237,7 +237,4 @@ func (test setClusterTest) run(t *testing.T) {
if len(test.expected) != 0 { if len(test.expected) != 0 {
assert.EqualValues(t, test.expected, buf.String()) assert.EqualValues(t, test.expected, buf.String())
} }
config.Clean(test.config)
config.Clean(afterRunConf)
} }

View File

@ -305,6 +305,12 @@ func (c *Config) PersistConfig() error {
return err return err
} }
// FIXME(howell): if this fails, then the results from the previous
// actions will persist, meaning that we might have overwritten our
// airshipconfig without updating our kubeconfig. A possible solution
// is to generate brand new config files and then write them at the
// end. That could still fail, but should be more robust
// Persist the kubeconfig file referenced // Persist the kubeconfig file referenced
if err := clientcmd.ModifyConfig(c.loadedPathOptions, *c.kubeConfig, true); err != nil { if err := clientcmd.ModifyConfig(c.loadedPathOptions, *c.kubeConfig, true); err != nil {
return err return err

View File

@ -18,6 +18,7 @@ package config
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -147,34 +148,18 @@ func TestEqual(t *testing.T) {
} }
func TestLoadConfig(t *testing.T) { func TestLoadConfig(t *testing.T) {
// Shouuld have the defult in testdata
// And copy it to the default prior to the test
// Create from defaults using existing kubeconf
conf := InitConfig(t) conf := InitConfig(t)
require.NotEmpty(t, conf.String()) require.NotEmpty(t, conf.String())
// Lets make sure that the contents is as expected
// 4 Clusters
// 2 Clusters Types
// 3 Contexts
// 2 Users
assert.Len(t, conf.Clusters, 4) assert.Len(t, conf.Clusters, 4)
require.Contains(t, conf.Clusters, "def")
assert.Len(t, conf.Clusters["def"].ClusterTypes, 2) assert.Len(t, conf.Clusters["def"].ClusterTypes, 2)
assert.Len(t, conf.Contexts, 3) assert.Len(t, conf.Contexts, 3)
assert.Len(t, conf.AuthInfos, 2) assert.Len(t, conf.AuthInfos, 2)
} }
func TestPersistConfig(t *testing.T) { func TestPersistConfig(t *testing.T) {
config := InitConfig(t) config := InitConfig(t)
defer Clean(config)
airConfigFile := filepath.Join(testAirshipConfigDir, AirshipConfig)
kConfigFile := filepath.Join(testAirshipConfigDir, AirshipKubeConfig)
config.SetLoadedConfigPath(airConfigFile)
kubePathOptions := clientcmd.NewDefaultPathOptions()
kubePathOptions.GlobalFile = kConfigFile
config.SetLoadedPathOptions(kubePathOptions)
err := config.PersistConfig() err := config.PersistConfig()
assert.NoErrorf(t, err, "Unable to persist configuration expected at %v", config.LoadedConfigPath()) assert.NoErrorf(t, err, "Unable to persist configuration expected at %v", config.LoadedConfigPath())
@ -183,21 +168,6 @@ func TestPersistConfig(t *testing.T) {
assert.NotNil(t, kpo) assert.NotNil(t, kpo)
} }
func TestPersistConfigFail(t *testing.T) {
config := InitConfig(t)
defer Clean(config)
airConfigFile := filepath.Join(testAirshipConfigDir, "\\")
kConfigFile := filepath.Join(testAirshipConfigDir, "\\")
config.SetLoadedConfigPath(airConfigFile)
kubePathOptions := clientcmd.NewDefaultPathOptions()
kubePathOptions.GlobalFile = kConfigFile
config.SetLoadedPathOptions(kubePathOptions)
err := config.PersistConfig()
assert.Errorf(t, err, "Able to persist configuration at %v, but expected an error", config.LoadedConfigPath())
}
func TestEnsureComplete(t *testing.T) { func TestEnsureComplete(t *testing.T) {
conf := InitConfig(t) conf := InitConfig(t)
@ -230,17 +200,20 @@ func TestEnsureComplete(t *testing.T) {
func TestPurge(t *testing.T) { func TestPurge(t *testing.T) {
config := InitConfig(t) config := InitConfig(t)
defer Clean(config)
airConfigFile := filepath.Join(testAirshipConfigDir, AirshipConfig) // Point the config objects at a temporary directory
kConfigFile := filepath.Join(testAirshipConfigDir, AirshipKubeConfig) tempDir, err := ioutil.TempDir("", "airship-test-purge")
require.NoError(t, err)
airConfigFile := filepath.Join(tempDir, AirshipConfig)
kConfigFile := filepath.Join(tempDir, AirshipKubeConfig)
config.SetLoadedConfigPath(airConfigFile) config.SetLoadedConfigPath(airConfigFile)
kubePathOptions := clientcmd.NewDefaultPathOptions() kubePathOptions := clientcmd.NewDefaultPathOptions()
kubePathOptions.GlobalFile = kConfigFile kubePathOptions.GlobalFile = kConfigFile
config.SetLoadedPathOptions(kubePathOptions) config.SetLoadedPathOptions(kubePathOptions)
// Store it // Store it
err := config.PersistConfig() err = config.PersistConfig()
assert.NoErrorf(t, err, "Unable to persist configuration expected at %v", config.LoadedConfigPath()) assert.NoErrorf(t, err, "Unable to persist configuration expected at %v", config.LoadedConfigPath())
// Verify that the file is there // Verify that the file is there

View File

@ -17,8 +17,8 @@ limitations under the License.
package config package config
import ( import (
"io/ioutil"
"net/url" "net/url"
"os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -28,13 +28,6 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
const (
testDataDir = "../../pkg/config/testdata"
testAirshipConfig = "testconfig"
testAirshipConfigDir = ".testairship"
testMimeType = ".yaml"
)
// DummyConfig used by tests, to initialize min set of data // DummyConfig used by tests, to initialize min set of data
func DummyConfig() *Config { func DummyConfig() *Config {
conf := &Config{ conf := &Config{
@ -119,42 +112,25 @@ func DummyClusterPurpose() *ClusterPurpose {
return cp return cp
} }
func InitConfigAt(t *testing.T, airConfigFile, kConfigFile string) *Config { func InitConfig(t *testing.T) *Config {
t.Helper()
testDir, err := ioutil.TempDir("", "airship-test")
configPath := filepath.Join(testDir, "config")
ioutil.WriteFile(configPath, []byte(testConfigYAML), 0666)
kubeConfigPath := filepath.Join(testDir, "kubeconfig")
ioutil.WriteFile(kubeConfigPath, []byte(testKubeConfigYAML), 0666)
conf := NewConfig() conf := NewConfig()
kubePathOptions := clientcmd.NewDefaultPathOptions() kubePathOptions := clientcmd.NewDefaultPathOptions()
kubePathOptions.GlobalFile = kConfigFile kubePathOptions.GlobalFile = kubeConfigPath
err = conf.LoadConfig(configPath, kubePathOptions)
err := conf.LoadConfig(airConfigFile, kubePathOptions)
require.NoError(t, err) require.NoError(t, err)
return conf return conf
} }
func InitConfig(t *testing.T) *Config {
airConfigFile := filepath.Join(testDataDir, AirshipConfig+testMimeType)
kConfigFile := filepath.Join(testDataDir, AirshipKubeConfig+testMimeType)
return InitConfigAt(t, airConfigFile, kConfigFile)
}
func DefaultInitConfig(t *testing.T) *Config {
conf := InitConfig(t)
airConfigFile := filepath.Join(AirshipConfigDir, AirshipConfig)
kConfigFile := filepath.Join(AirshipConfigDir, AirshipKubeConfig)
conf.SetLoadedConfigPath(airConfigFile)
kubePathOptions := clientcmd.NewDefaultPathOptions()
kubePathOptions.GlobalFile = kConfigFile
conf.SetLoadedPathOptions(kubePathOptions)
return conf
}
func Clean(conf *Config) error {
configDir := filepath.Dir(conf.LoadedConfigPath())
err := os.RemoveAll(configDir)
if !os.IsNotExist(err) {
return err
}
return nil
}
func DummyClusterOptions() *ClusterOptions { func DummyClusterOptions() *ClusterOptions {
co := &ClusterOptions{} co := &ClusterOptions{}
@ -167,3 +143,88 @@ func DummyClusterOptions() *ClusterOptions {
return co return co
} }
const (
testConfigYAML = `apiVersion: airshipit.org/v1alpha1
clusters:
def:
cluster-type:
ephemeral:
bootstrap-info: ""
cluster-kubeconf: def_ephemeral
target:
bootstrap-info: ""
cluster-kubeconf: def_target
onlyinkubeconf:
cluster-type:
target:
bootstrap-info: ""
cluster-kubeconf: onlyinkubeconf_target
wrongonlyinconfig:
cluster-type: {}
wrongonlyinkubeconf:
cluster-type:
target:
bootstrap-info: ""
cluster-kubeconf: wrongonlyinkubeconf_target
contexts:
def_ephemeral:
context-kubeconf: def_ephemeral
def_target:
context-kubeconf: def_target
onlyink:
context-kubeconf: onlyinkubeconf_target
current-context: ""
kind: Config
manifests: {}
modules-config:
dummy-for-tests: ""
users:
k-admin: {}
k-other: {}`
//nolint:lll
testKubeConfigYAML = `apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: http://5.6.7.8
name: def_ephemeral
- cluster:
insecure-skip-tls-verify: true
server: http://1.2.3.4
name: def_target
- cluster:
insecure-skip-tls-verify: true
server: http://9.10.11.12
name: onlyinkubeconf_target
- cluster:
certificate-authority: cert_file
server: ""
name: wrongonlyinkubeconf_target
contexts:
- context:
cluster: def_ephemeral
user: k-admin
name: def_ephemeral
- context:
cluster: def_target
user: k-admin
name: def_target
- context:
cluster: onlyinkubeconf_target
user: k-other
name: onlyink
current-context: ""
kind: Config
preferences: {}
users:
- name: k-admin
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJQXhEdzk2RUY4SXN3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4T1RBNU1qa3hOekF6TURsYUZ3MHlNREE1TWpneE56QXpNVEphTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXV6R0pZdlBaNkRvaTQyMUQKSzhXSmFaQ25OQWQycXo1cC8wNDJvRnpRUGJyQWd6RTJxWVZrek9MOHhBVmVSN1NONXdXb1RXRXlGOEVWN3JyLwo0K0hoSEdpcTVQbXF1SUZ5enpuNi9JWmM4alU5eEVmenZpa2NpckxmVTR2UlhKUXdWd2dBU05sMkFXQUloMmRECmRUcmpCQ2ZpS1dNSHlqMFJiSGFsc0J6T3BnVC9IVHYzR1F6blVRekZLdjJkajVWMU5rUy9ESGp5UlJKK0VMNlEKQlltR3NlZzVQNE5iQzllYnVpcG1NVEFxL0p1bU9vb2QrRmpMMm5acUw2Zkk2ZkJ0RjVPR2xwQ0IxWUo4ZnpDdApHUVFaN0hUSWJkYjJ0cDQzRlZPaHlRYlZjSHFUQTA0UEoxNSswV0F5bVVKVXo4WEE1NDRyL2J2NzRKY0pVUkZoCmFyWmlRd0lEQVFBQm95Y3dK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ZXdWd1BjRzQxR2hQclNUZEJxdHFac1doWGE3aDdLTWEKeHdvamh5SXpnTXNyK2tXODdlajhDQ2h0d21sQ1p5QU92QmdOZytncnJ1cEZLM3FOSkpKeU9YREdHckdpbzZmTQp5aXB3Q2tZVGVxRThpZ1J6UkI5QkdFUGY4eVpjMUtwdmZhUDVhM0lRZmxiV0czbGpUemNNZVZjPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=`
)

View File

@ -1,37 +0,0 @@
apiVersion: airshipit.org/v1alpha1
clusters:
def:
cluster-type:
ephemeral:
bootstrap-info: ""
cluster-kubeconf: def_ephemeral
target:
bootstrap-info: ""
cluster-kubeconf: def_target
onlyinkubeconf:
cluster-type:
target:
bootstrap-info: ""
cluster-kubeconf: onlyinkubeconf_target
wrongonlyinconfig:
cluster-type: {}
wrongonlyinkubeconf:
cluster-type:
target:
bootstrap-info: ""
cluster-kubeconf: wrongonlyinkubeconf_target
contexts:
def_ephemeral:
context-kubeconf: def_ephemeral
def_target:
context-kubeconf: def_target
onlyink:
context-kubeconf: onlyinkubeconf_target
current-context: ""
kind: Config
manifests: {}
modules-config:
dummy-for-tests: ""
users:
k-admin: {}
k-other: {}

View File

@ -1,43 +0,0 @@
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: http://5.6.7.8
name: def_ephemeral
- cluster:
insecure-skip-tls-verify: true
server: http://1.2.3.4
name: def_target
- cluster:
insecure-skip-tls-verify: true
server: http://9.10.11.12
name: onlyinkubeconf_target
- cluster:
certificate-authority: cert_file
server: ""
name: wrongonlyinkubeconf_target
contexts:
- context:
cluster: def_ephemeral
user: k-admin
name: def_ephemeral
- context:
cluster: def_target
user: k-admin
name: def_target
- context:
cluster: onlyinkubeconf_target
user: k-other
name: onlyink
current-context: ""
kind: Config
preferences: {}
users:
- name: k-admin
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJQ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xNTFUK1RRT1UzdkpGQjc1QW9HQkFPTHcKalp1cnZtVkZyTHdaVGgvRDNpWll5SVV0ZUljZ2NKLzlzbTh6L0pPRmRIbFd4dGRHUFVzYVd1MnBTNEhvckFtbgpqTm4vSTluUXd3enZ3MWUzVVFPbUhMRjVBczk4VU5hbk5TQ0xNMW1yaXZHRXJ1VHFnTDM1bU41eFZPdTUxQU5JCm4yNkFtODBJT2JDeEtLa0R0ZXJSaFhHd3g5c1pONVJCbG9VRThZNGJBb0dBQ3ZsdVhMZWRxcng5VkE0bDNoNXUKVDJXRVUxYjgxZ1orcmtRc1I1S0lNWEw4cllBTElUNUpHKzFuendyN3BkaEFXZmFWdVV2SDRhamdYT0h6MUs5aQpFODNSVTNGMG9ldUg0V01PY1RwU0prWm0xZUlXcWRiaEVCb1FGdUlWTXRib1BsV0d4ZUhFRHJoOEtreGp4aThSCmdEcUQyajRwY1IzQ0g5QjJ5a0lqQjVFQ2dZRUExc0xXLys2enE1c1lNSm14K1JXZThhTXJmL3pjQnVTSU1LQWgKY0dNK0wwMG9RSHdDaUU4TVNqcVN1ajV3R214YUFuanhMb3ZwSFlRV1VmUEVaUW95UE1YQ2VhRVBLOU4xbk8xMwp0V2lHRytIZkIxaU5PazFCc0lhNFNDbndOM1FRVTFzeXBaeEgxT3hueS9LYmkvYmEvWEZ5VzNqMGFUK2YvVWxrCmJGV1ZVdWtDZ1lFQTBaMmRTTFlmTjV5eFNtYk5xMWVqZXdWd1BjRzQxR2hQclNUZEJxdHFac1doWGE3aDdLTWEKeHdvamh5SXpnTXNyK2tXODdlajhDQ2h0d21sQ1p5QU92QmdOZytncnJ1cEZLM3FOSkpKeU9YREdHckdpbzZmTQp5aXB3Q2tZVGVxRThpZ1J6UkI5QkdFUGY4eVpjMUtwdmZhUDVhM0lRZmxiV0czbGpUemNNZVZjPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=

View File

@ -17,8 +17,6 @@ limitations under the License.
package environment package environment
import ( import (
"fmt"
"io"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -30,11 +28,6 @@ import (
"opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/config"
) )
const (
testDataDir = "../../pkg/config/testdata"
testMimeType = ".yaml"
)
// Bogus for coverage // Bogus for coverage
func FakeCmd() *cobra.Command { func FakeCmd() *cobra.Command {
fakecmd := &cobra.Command{ fakecmd := &cobra.Command{
@ -45,31 +38,11 @@ func FakeCmd() *cobra.Command {
} }
func TestInitFlags(t *testing.T) { func TestInitFlags(t *testing.T) {
// Get the Environment // Get the Environment
settings := &AirshipCTLSettings{} settings := &AirshipCTLSettings{}
fakecmd := FakeCmd() fakecmd := FakeCmd()
settings.InitFlags(fakecmd) settings.InitFlags(fakecmd)
assert.True(t, fakecmd.HasPersistentFlags()) assert.True(t, fakecmd.HasPersistentFlags())
}
func TestNewConfig(t *testing.T) {
// Initialize kubeconfig
src := filepath.Join(testDataDir, config.AirshipKubeConfig+testMimeType)
dst := filepath.Join(config.AirshipConfigDir, config.AirshipKubeConfig)
err := initTestDir(config.AirshipConfigDir)
require.NoError(t, err)
defer clean(config.AirshipConfigDir)
_, err = copy(src, dst)
require.NoError(t, err)
settings := &AirshipCTLSettings{}
settings.InitConfig()
conf := settings.Config()
assert.NotNil(t, conf)
} }
func TestSpecifyAirConfigFromEnv(t *testing.T) { func TestSpecifyAirConfigFromEnv(t *testing.T) {
@ -101,36 +74,3 @@ func TestSpecifyKubeConfigInCli(t *testing.T) {
settings.InitFlags(fakecmd) settings.InitFlags(fakecmd)
assert.True(t, fakecmd.HasPersistentFlags()) assert.True(t, fakecmd.HasPersistentFlags())
} }
func initTestDir(dst string) error {
return os.MkdirAll(dst, 0755)
}
func copy(src, dst string) (int64, error) {
sourceFileStat, err := os.Stat(src)
if err != nil {
return 0, err
}
if !sourceFileStat.Mode().IsRegular() {
return 0, fmt.Errorf("%s is not a regular file", src)
}
source, err := os.Open(src)
if err != nil {
return 0, err
}
defer source.Close()
destination, err := os.Create(dst)
if err != nil {
return 0, err
}
defer destination.Close()
nBytes, err := io.Copy(destination, source)
return nBytes, err
}
func clean(dst string) error {
return os.RemoveAll(dst)
}

View File

@ -32,7 +32,6 @@ func SetupTestFs(t *testing.T, fixtureDir string) fs.FileSystem {
require.NoErrorf(t, err, "Failed to write file %s, setting up testfs failed", filePath) require.NoErrorf(t, err, "Failed to write file %s, setting up testfs failed", filePath)
} }
return x return x
} }
// NewTestBundle helps to create a new bundle with FakeFs containing documents from fixtureDir // NewTestBundle helps to create a new bundle with FakeFs containing documents from fixtureDir