@@ -10,6 +10,7 @@ import (
10
10
"io"
11
11
"os"
12
12
"os/exec"
13
+ "path/filepath"
13
14
"strings"
14
15
"testing"
15
16
@@ -27,6 +28,7 @@ func TestRemoteLoad_LocalProtocol(t *testing.T) {
27
28
root string
28
29
simple string
29
30
noSuffix string
31
+ hash string
30
32
multiBaseDev string
31
33
withSubmodule string
32
34
}
@@ -35,9 +37,10 @@ func TestRemoteLoad_LocalProtocol(t *testing.T) {
35
37
// root/
36
38
// simple.git/ - base with just a pod
37
39
// nosuffix/ - same as simple.git/ without the .git suffix
40
+ // hash-xx/ - same as simple.git/ with random hash at xx
38
41
// multibase.git/ - base with a dev overlay
39
42
// with-submodule.git/ - includes `simple` as a submodule
40
- // submodule/ - the submodule referencing `simple
43
+ // submodule/ - the submodule referencing `simple`
41
44
createGitRepos := func (t * testing.T ) testRepos {
42
45
t .Helper ()
43
46
@@ -49,10 +52,16 @@ func TestRemoteLoad_LocalProtocol(t *testing.T) {
49
52
}
50
53
}
51
54
root := t .TempDir ()
55
+
56
+ hashPath , err := os .MkdirTemp (root , "hash-" )
57
+ require .NoError (t , err )
58
+ hashDir := filepath .Base (hashPath )
59
+
52
60
bash (fmt .Sprintf (`
53
61
set -eux
54
62
55
63
export ROOT="%s"
64
+ export HASH_DIR="%s"
56
65
57
66
export GIT_AUTHOR_NAME=Nobody
58
67
@@ -84,19 +93,27 @@ cp -r testdata/remoteload/multibase $ROOT/multibase.git
84
93
git add .
85
94
git commit -m "import"
86
95
)
96
+ cp -r testdata/remoteload/with-submodule $ROOT/with-submodule.git # see README
97
+ cp -r $ROOT/simple.git/. $ROOT/$HASH_DIR
87
98
(
88
- mkdir $ROOT/with-submodule.git
89
99
cd $ROOT/with-submodule.git
90
100
git init --initial-branch=main
91
- git submodule add $ROOT/simple.git submodule
101
+ git add .
92
102
git commit -m "import"
103
+ git checkout -b relative-submodule
104
+ git submodule add ../$HASH_DIR submodule
105
+ git commit -m "relative submodule"
106
+ git checkout main
107
+ git submodule add $ROOT/simple.git submodule
108
+ git commit -m "submodule"
93
109
)
94
- ` , root ))
110
+ ` , root , hashDir ))
95
111
return testRepos {
96
112
root : root ,
97
113
// The strings below aren't currently used, and more serve as documentation.
98
114
simple : "simple.git" ,
99
115
noSuffix : "nosuffix" ,
116
+ hash : hashDir ,
100
117
multiBaseDev : "multibase.git" ,
101
118
withSubmodule : "with-submodule.git" ,
102
119
}
@@ -182,6 +199,15 @@ resources:
182
199
` ,
183
200
expected : simpleBuild ,
184
201
},
202
+ {
203
+ name : "has relative submodule" ,
204
+ kustomization : `
205
+ resources:
206
+ - file://$ROOT/with-submodule.git/submodule?ref=relative-submodule
207
+ ` ,
208
+ // TODO(annasong): Replace with simpleBuild once #5131 is fixed.
209
+ err : `failed to run '\S+/git submodule update --init --recursive'` ,
210
+ },
185
211
{
186
212
name : "has timeout" ,
187
213
kustomization : `
@@ -272,7 +298,7 @@ resources:
272
298
273
299
if test .err != "" {
274
300
require .Error (t , err )
275
- require .Contains (t , err .Error (), test . err )
301
+ require .Regexp (t , test . err , err .Error ())
276
302
} else {
277
303
require .NoError (t , err )
278
304
checkYaml (t , m , strings .ReplaceAll (test .expected , "$ROOT" , repos .root ))
0 commit comments