From 61eecca7f3f40f72964bcec65a15a54b9a040fe9 Mon Sep 17 00:00:00 2001 From: Ian Howell Date: Tue, 12 Nov 2019 14:13:55 -0600 Subject: [PATCH] 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 --- cmd/config/get_cluster_test.go | 17 ++-- cmd/config/set_cluster_test.go | 19 ++-- pkg/config/config.go | 6 ++ pkg/config/config_test.go | 45 ++-------- pkg/config/test_utils.go | 135 ++++++++++++++++++++-------- pkg/config/testdata/config.yaml | 37 -------- pkg/config/testdata/kubeconfig.yaml | 43 --------- pkg/environment/settings_test.go | 60 ------------- testutil/testdatafs.go | 1 - 9 files changed, 129 insertions(+), 234 deletions(-) delete mode 100644 pkg/config/testdata/config.yaml delete mode 100644 pkg/config/testdata/kubeconfig.yaml diff --git a/cmd/config/get_cluster_test.go b/cmd/config/get_cluster_test.go index f99ce4627..d1cc8d4bf 100644 --- a/cmd/config/get_cluster_test.go +++ b/cmd/config/get_cluster_test.go @@ -18,6 +18,7 @@ package config import ( "bytes" + "path/filepath" "testing" "github.com/stretchr/testify/assert" @@ -34,11 +35,6 @@ type getClusterTest struct { expected string } -const ( - testMimeType = ".yaml" - testDataDir = "../../pkg/config/testdata" -) - func TestGetCluster(t *testing.T) { tname := "def" tctype := config.Ephemeral @@ -69,12 +65,15 @@ func TestGetCluster(t *testing.T) { func TestGetAllClusters(t *testing.T) { conf := config.InitConfig(t) + testDir := filepath.Dir(conf.LoadedConfigPath()) + kubeconfigPath := filepath.Join(testDir, "kubeconfig") + expected := `Cluster: def ephemeral: bootstrap-info: "" cluster-kubeconf: def_ephemeral -LocationOfOrigin: ../../pkg/config/testdata/kubeconfig.yaml +LocationOfOrigin: ` + kubeconfigPath + ` insecure-skip-tls-verify: true server: http://5.6.7.8 @@ -83,7 +82,7 @@ target: bootstrap-info: "" cluster-kubeconf: def_target -LocationOfOrigin: ../../pkg/config/testdata/kubeconfig.yaml +LocationOfOrigin: ` + kubeconfigPath + ` insecure-skip-tls-verify: true server: http://1.2.3.4 @@ -92,7 +91,7 @@ target: bootstrap-info: "" cluster-kubeconf: onlyinkubeconf_target -LocationOfOrigin: ../../pkg/config/testdata/kubeconfig.yaml +LocationOfOrigin: ` + kubeconfigPath + ` insecure-skip-tls-verify: true server: http://9.10.11.12 @@ -101,7 +100,7 @@ target: bootstrap-info: "" cluster-kubeconf: wrongonlyinkubeconf_target -LocationOfOrigin: ../../pkg/config/testdata/kubeconfig.yaml +LocationOfOrigin: ` + kubeconfigPath + ` certificate-authority: cert_file server: "" diff --git a/cmd/config/set_cluster_test.go b/cmd/config/set_cluster_test.go index 36334cc0c..7452dd21b 100644 --- a/cmd/config/set_cluster_test.go +++ b/cmd/config/set_cluster_test.go @@ -44,13 +44,13 @@ const ( ) func TestSetClusterWithCAFile(t *testing.T) { - conf := config.DefaultInitConfig(t) + conf := config.InitConfig(t) certFile := "../../pkg/config/testdata/ca.crt" tname := testCluster tctype := config.Ephemeral - expconf := config.DefaultInitConfig(t) + expconf := config.InitConfig(t) expconf.Clusters[tname] = config.NewClusterPurpose() expconf.Clusters[tname].ClusterTypes[tctype] = config.NewCluster() clusterName := config.NewClusterComplexName() @@ -78,13 +78,13 @@ func TestSetClusterWithCAFile(t *testing.T) { test.run(t) } func TestSetClusterWithCAFileData(t *testing.T) { - conf := config.DefaultInitConfig(t) + conf := config.InitConfig(t) certFile := "../../pkg/config/testdata/ca.crt" tname := testCluster tctype := config.Ephemeral - expconf := config.DefaultInitConfig(t) + expconf := config.InitConfig(t) expconf.Clusters[tname] = config.NewClusterPurpose() expconf.Clusters[tname].ClusterTypes[tctype] = config.NewCluster() clusterName := config.NewClusterComplexName() @@ -117,7 +117,7 @@ func TestSetClusterWithCAFileData(t *testing.T) { func TestSetCluster(t *testing.T) { - conf := config.DefaultInitConfig(t) + conf := config.InitConfig(t) // err := conf.Purge() // assert.Nilf(t, err, "Unable to purge test configuration %v", err) @@ -125,7 +125,7 @@ func TestSetCluster(t *testing.T) { tname := testCluster tctype := config.Ephemeral - expconf := config.DefaultInitConfig(t) + expconf := config.InitConfig(t) expconf.Clusters[tname] = config.NewClusterPurpose() expconf.Clusters[tname].ClusterTypes[tctype] = config.NewCluster() clusterName := config.NewClusterComplexName() @@ -156,7 +156,7 @@ func TestModifyCluster(t *testing.T) { tname := testClusterName tctype := config.Ephemeral - conf := config.DefaultInitConfig(t) + conf := config.InitConfig(t) conf.Clusters[tname] = config.NewClusterPurpose() clusterName := config.NewClusterComplexName() clusterName.WithType(tname, tctype) @@ -167,7 +167,7 @@ func TestModifyCluster(t *testing.T) { conf.KubeConfig().Clusters[clusterName.Name()] = kCluster conf.Clusters[tname].ClusterTypes[tctype].SetKubeCluster(kCluster) - expconf := config.DefaultInitConfig(t) + expconf := config.InitConfig(t) expconf.Clusters[tname] = config.NewClusterPurpose() expconf.Clusters[tname].ClusterTypes[tctype] = config.NewCluster() expconf.Clusters[tname].ClusterTypes[tctype].NameInKubeconf = clusterName.Name() @@ -237,7 +237,4 @@ func (test setClusterTest) run(t *testing.T) { if len(test.expected) != 0 { assert.EqualValues(t, test.expected, buf.String()) } - - config.Clean(test.config) - config.Clean(afterRunConf) } diff --git a/pkg/config/config.go b/pkg/config/config.go index 845eb22fe..a08650582 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -305,6 +305,12 @@ func (c *Config) PersistConfig() error { 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 if err := clientcmd.ModifyConfig(c.loadedPathOptions, *c.kubeConfig, true); err != nil { return err diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 46ac52e39..186253e95 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -18,6 +18,7 @@ package config import ( "fmt" + "io/ioutil" "os" "path/filepath" "testing" @@ -147,34 +148,18 @@ func TestEqual(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) - 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) + require.Contains(t, conf.Clusters, "def") assert.Len(t, conf.Clusters["def"].ClusterTypes, 2) assert.Len(t, conf.Contexts, 3) assert.Len(t, conf.AuthInfos, 2) - } func TestPersistConfig(t *testing.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() 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) } -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) { conf := InitConfig(t) @@ -230,17 +200,20 @@ func TestEnsureComplete(t *testing.T) { func TestPurge(t *testing.T) { config := InitConfig(t) - defer Clean(config) - airConfigFile := filepath.Join(testAirshipConfigDir, AirshipConfig) - kConfigFile := filepath.Join(testAirshipConfigDir, AirshipKubeConfig) + // Point the config objects at a temporary directory + tempDir, err := ioutil.TempDir("", "airship-test-purge") + require.NoError(t, err) + + airConfigFile := filepath.Join(tempDir, AirshipConfig) + kConfigFile := filepath.Join(tempDir, AirshipKubeConfig) config.SetLoadedConfigPath(airConfigFile) kubePathOptions := clientcmd.NewDefaultPathOptions() kubePathOptions.GlobalFile = kConfigFile config.SetLoadedPathOptions(kubePathOptions) // Store it - err := config.PersistConfig() + err = config.PersistConfig() assert.NoErrorf(t, err, "Unable to persist configuration expected at %v", config.LoadedConfigPath()) // Verify that the file is there diff --git a/pkg/config/test_utils.go b/pkg/config/test_utils.go index 8b48bce70..aa2eaa9f0 100644 --- a/pkg/config/test_utils.go +++ b/pkg/config/test_utils.go @@ -17,8 +17,8 @@ limitations under the License. package config import ( + "io/ioutil" "net/url" - "os" "path/filepath" "testing" @@ -28,13 +28,6 @@ import ( "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 func DummyConfig() *Config { conf := &Config{ @@ -119,42 +112,25 @@ func DummyClusterPurpose() *ClusterPurpose { 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() kubePathOptions := clientcmd.NewDefaultPathOptions() - kubePathOptions.GlobalFile = kConfigFile - - err := conf.LoadConfig(airConfigFile, kubePathOptions) + kubePathOptions.GlobalFile = kubeConfigPath + err = conf.LoadConfig(configPath, kubePathOptions) require.NoError(t, err) 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 { co := &ClusterOptions{} @@ -167,3 +143,88 @@ func DummyClusterOptions() *ClusterOptions { 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: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJQXhEdzk2RUY4SXN3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4T1RBNU1qa3hOekF6TURsYUZ3MHlNREE1TWpneE56QXpNVEphTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXV6R0pZdlBaNkRvaTQyMUQKSzhXSmFaQ25OQWQycXo1cC8wNDJvRnpRUGJyQWd6RTJxWVZrek9MOHhBVmVSN1NONXdXb1RXRXlGOEVWN3JyLwo0K0hoSEdpcTVQbXF1SUZ5enpuNi9JWmM4alU5eEVmenZpa2NpckxmVTR2UlhKUXdWd2dBU05sMkFXQUloMmRECmRUcmpCQ2ZpS1dNSHlqMFJiSGFsc0J6T3BnVC9IVHYzR1F6blVRekZLdjJkajVWMU5rUy9ESGp5UlJKK0VMNlEKQlltR3NlZzVQNE5iQzllYnVpcG1NVEFxL0p1bU9vb2QrRmpMMm5acUw2Zkk2ZkJ0RjVPR2xwQ0IxWUo4ZnpDdApHUVFaN0hUSWJkYjJ0cDQzRlZPaHlRYlZjSHFUQTA0UEoxNSswV0F5bVVKVXo4WEE1NDRyL2J2NzRKY0pVUkZoCmFyWmlRd0lEQVFBQm95Y3dKVEFPQmdOVkhROEJBZjhFQkFNQ0JhQXdFd1lEVlIwbEJBd3dDZ1lJS3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yK2tXODdlajhDQ2h0d21sQ1p5QU92QmdOZytncnJ1cEZLM3FOSkpKeU9YREdHckdpbzZmTQp5aXB3Q2tZVGVxRThpZ1J6UkI5QkdFUGY4eVpjMUtwdmZhUDVhM0lRZmxiV0czbGpUemNNZVZjPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=` +) diff --git a/pkg/config/testdata/config.yaml b/pkg/config/testdata/config.yaml deleted file mode 100644 index 0bd4c80a6..000000000 --- a/pkg/config/testdata/config.yaml +++ /dev/null @@ -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: {} diff --git a/pkg/config/testdata/kubeconfig.yaml b/pkg/config/testdata/kubeconfig.yaml deleted file mode 100644 index 027fa967a..000000000 --- a/pkg/config/testdata/kubeconfig.yaml +++ /dev/null @@ -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: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJQXhEdzk2RUY4SXN3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4T1RBNU1qa3hOekF6TURsYUZ3MHlNREE1TWpneE56QXpNVEphTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXV6R0pZdlBaNkRvaTQyMUQKSzhXSmFaQ25OQWQycXo1cC8wNDJvRnpRUGJyQWd6RTJxWVZrek9MOHhBVmVSN1NONXdXb1RXRXlGOEVWN3JyLwo0K0hoSEdpcTVQbXF1SUZ5enpuNi9JWmM4alU5eEVmenZpa2NpckxmVTR2UlhKUXdWd2dBU05sMkFXQUloMmRECmRUcmpCQ2ZpS1dNSHlqMFJiSGFsc0J6T3BnVC9IVHYzR1F6blVRekZLdjJkajVWMU5rUy9ESGp5UlJKK0VMNlEKQlltR3NlZzVQNE5iQzllYnVpcG1NVEFxL0p1bU9vb2QrRmpMMm5acUw2Zkk2ZkJ0RjVPR2xwQ0IxWUo4ZnpDdApHUVFaN0hUSWJkYjJ0cDQzRlZPaHlRYlZjSHFUQTA0UEoxNSswV0F5bVVKVXo4WEE1NDRyL2J2NzRKY0pVUkZoCmFyWmlRd0lEQVFBQm95Y3dKVEFPQmdOVkhROEJBZjhFQkFNQ0JhQXdFd1lEVlIwbEJBd3dDZ1lJS3dZQkJRVUgKQXdJd0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFMMmhIUmVibEl2VHJTMFNmUVg1RG9ueVVh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ThpZ1J6UkI5QkdFUGY4eVpjMUtwdmZhUDVhM0lRZmxiV0czbGpUemNNZVZjPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo= diff --git a/pkg/environment/settings_test.go b/pkg/environment/settings_test.go index 46cc185d0..8e6d15a89 100644 --- a/pkg/environment/settings_test.go +++ b/pkg/environment/settings_test.go @@ -17,8 +17,6 @@ limitations under the License. package environment import ( - "fmt" - "io" "os" "path/filepath" "testing" @@ -30,11 +28,6 @@ import ( "opendev.org/airship/airshipctl/pkg/config" ) -const ( - testDataDir = "../../pkg/config/testdata" - testMimeType = ".yaml" -) - // Bogus for coverage func FakeCmd() *cobra.Command { fakecmd := &cobra.Command{ @@ -45,31 +38,11 @@ func FakeCmd() *cobra.Command { } func TestInitFlags(t *testing.T) { - // Get the Environment settings := &AirshipCTLSettings{} fakecmd := FakeCmd() settings.InitFlags(fakecmd) 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) { @@ -101,36 +74,3 @@ func TestSpecifyKubeConfigInCli(t *testing.T) { settings.InitFlags(fakecmd) 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) -} diff --git a/testutil/testdatafs.go b/testutil/testdatafs.go index e38731930..9ec6f4a7c 100644 --- a/testutil/testdatafs.go +++ b/testutil/testdatafs.go @@ -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) } return x - } // NewTestBundle helps to create a new bundle with FakeFs containing documents from fixtureDir