1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-12 18:59:50 +03:00
aports/testing/kubectl-krew/test-use-testing-tmpdir.patch
Kevin Daudt dbfc838472 testing/kubectl-krew: fix tests due to lingering index cache
> --- FAIL: TestKrewUpdateListsUpgradesAvailable (1.82s)
> [..]
> update_test.go:129: output should not mention update available for "ns"; output=Updated the local copy of plugin index.
> [..]
> FAIL
> FAIL	sigs.k8s.io/krew/integration_test	70.448s
2023-08-14 20:18:24 +00:00

15 lines
769 B
Diff

Outdated index files from previous builds break tests. Use t.TempDir() to make
sure a new index file is used.
diff --git a/integration_test/testutil_test.go b/integration_test/testutil_test.go
index 66ebc98..d91635b 100644
--- a/integration_test/testutil_test.go
+++ b/integration_test/testutil_test.go
@@ -277,7 +277,7 @@ func (it *ITest) loadReceipt(path string) index.Receipt {
// It caches the index tree as in-memory tar after the first run.
func (it *ITest) initializeIndex() {
initIndexOnce.Do(func() {
- persistentCacheFile := filepath.Join(os.TempDir(), persistentIndexCache)
+ persistentCacheFile := filepath.Join(it.t.TempDir(), persistentIndexCache)
fileInfo, err := os.Stat(persistentCacheFile)
if err == nil && fileInfo.Mode().IsRegular() {