@@ -90,3 +90,93 @@ load 'test-helper'
9090 [ " $output " = " 1" ]
9191}
9292
93+ @test " repo cache directory auto-creation with absolute path" {
94+ # Clean up any existing cache
95+ rm -rf " /tmp/test-auto-cache-repo"
96+
97+ # Set cache to non-existent directory with absolute path
98+ HELM_GIT_REPO_CACHE=" /tmp/test-auto-cache-repo"
99+ export HELM_GIT_REPO_CACHE
100+
101+ run helm_init " $HELM_HOME "
102+ [ $status = 0 ]
103+ run " $HELM_BIN " plugin install " $HELM_GIT_DIRNAME "
104+ [ $status = 0 ]
105+
106+ # This should automatically create the cache directory
107+ run " $HELM_BIN " fetch -d " $HELM_GIT_OUTPUT " " git+https://github.com/jetstack/cert-manager@contrib/charts/index.yaml?ref=v0.5.2"
108+ [ $status = 0 ]
109+
110+ # Verify the cache directory was created and has content
111+ run stat " /tmp/test-auto-cache-repo"
112+ [ $status = 0 ]
113+ run stat " /tmp/test-auto-cache-repo/github.com/jetstack/cert-manager"
114+ [ $status = 0 ]
115+
116+ # Clean up
117+ rm -rf " /tmp/test-auto-cache-repo"
118+ }
119+
120+ @test " chart cache directory auto-creation with absolute path" {
121+ # Clean up any existing cache
122+ rm -rf " /tmp/test-auto-cache-chart"
123+
124+ # Set cache to non-existent directory with absolute path
125+ HELM_GIT_CHART_CACHE=" /tmp/test-auto-cache-chart"
126+ export HELM_GIT_CHART_CACHE
127+
128+ run helm_init " $HELM_HOME "
129+ [ $status = 0 ]
130+ run " $HELM_BIN " plugin install " $HELM_GIT_DIRNAME "
131+ [ $status = 0 ]
132+
133+ # This should automatically create the cache directory
134+ run " $HELM_BIN " fetch -d " $HELM_GIT_OUTPUT " " git+https://github.com/jetstack/cert-manager@contrib/charts/index.yaml?ref=v0.5.2"
135+ [ $status = 0 ]
136+
137+ # Verify the cache directory was created and has content
138+ run stat " /tmp/test-auto-cache-chart"
139+ [ $status = 0 ]
140+ # The exact hash subdirectory name varies, so just check that something was created
141+ run sh -c " ls '/tmp/test-auto-cache-chart' | wc -l"
142+ [ " $output " -gt 0 ]
143+
144+ # Clean up
145+ rm -rf " /tmp/test-auto-cache-chart"
146+ }
147+
148+ @test " both cache directories auto-creation with nested paths" {
149+ # Clean up any existing cache
150+ rm -rf " /tmp/test-cache"
151+
152+ # Set both caches to non-existent nested directories
153+ HELM_GIT_REPO_CACHE=" /tmp/test-cache/helm-git/repo"
154+ HELM_GIT_CHART_CACHE=" /tmp/test-cache/helm-git/chart"
155+ export HELM_GIT_REPO_CACHE
156+ export HELM_GIT_CHART_CACHE
157+
158+ run helm_init " $HELM_HOME "
159+ [ $status = 0 ]
160+ run " $HELM_BIN " plugin install " $HELM_GIT_DIRNAME "
161+ [ $status = 0 ]
162+
163+ # This should automatically create both cache directories
164+ run " $HELM_BIN " fetch -d " $HELM_GIT_OUTPUT " " git+https://github.com/jetstack/cert-manager@contrib/charts/index.yaml?ref=v0.5.2"
165+ [ $status = 0 ]
166+
167+ # Verify both cache directories were created
168+ run stat " /tmp/test-cache/helm-git/repo"
169+ [ $status = 0 ]
170+ run stat " /tmp/test-cache/helm-git/chart"
171+ [ $status = 0 ]
172+
173+ # Verify they have content
174+ run stat " /tmp/test-cache/helm-git/repo/github.com/jetstack/cert-manager"
175+ [ $status = 0 ]
176+ run sh -c " ls '/tmp/test-cache/helm-git/chart' | wc -l"
177+ [ " $output " -gt 0 ]
178+
179+ # Clean up
180+ rm -rf " /tmp/test-cache"
181+ }
182+
0 commit comments