Fix a failure when running unit tests locally

This change fixes an issue in pkg/k8s/client.TestNewClient in which the
unit test was using the developer's real airship config file. This was,
in some cases, causing unit tests to fail when run locally.

Change-Id: Ic8911b9e72d3e76f0219472ea0a9de5b3b255c3b
This commit is contained in:
Ian Howell 2020-03-13 11:18:37 -05:00
parent 2ccb060c61
commit 5eec83e05f

View File

@ -1,4 +1,4 @@
package client
package client_test
import (
"path/filepath"
@ -8,6 +8,8 @@ import (
"github.com/stretchr/testify/require"
"opendev.org/airship/airshipctl/pkg/environment"
"opendev.org/airship/airshipctl/pkg/k8s/client"
"opendev.org/airship/airshipctl/testutil"
)
const (
@ -15,9 +17,11 @@ const (
airshipConfigDir = "testdata"
)
func TestNewclient(t *testing.T) {
func TestNewClient(t *testing.T) {
settings := &environment.AirshipCTLSettings{}
settings.InitConfig()
conf, cleanup := testutil.InitConfig(t)
defer cleanup(t)
settings.SetConfig(conf)
akp, err := filepath.Abs(kubeconfigPath)
require.NoError(t, err)
@ -28,7 +32,7 @@ func TestNewclient(t *testing.T) {
settings.SetAirshipConfigPath(adir)
settings.SetKubeConfigPath(akp)
client, err := NewClient(settings)
client, err := client.NewClient(settings)
assert.NoError(t, err)
assert.NotNil(t, client)
assert.NotNil(t, client.ClientSet())