mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-01 00:23:56 +08:00 
			
		
		
		
	tests: add bake test for remote subdir context
Fixed in 12b6a3ad9a, but now we have
regression tests! So we can add a check that we don't break this
behavior again.
Signed-off-by: Justin Chadwell <me@jedevc.com>
			
			
This commit is contained in:
		| @@ -22,6 +22,7 @@ var bakeTests = []func(t *testing.T, sb integration.Sandbox){ | ||||
| 	testBakeRemote, | ||||
| 	testBakeRemoteCmdContext, | ||||
| 	testBakeRemoteCmdContextOverride, | ||||
| 	testBakeRemoteContextSubdir, | ||||
| } | ||||
|  | ||||
| func testBakeRemote(t *testing.T, sb integration.Sandbox) { | ||||
| @@ -127,3 +128,37 @@ EOT | ||||
|  | ||||
| 	require.FileExists(t, filepath.Join(dirDest, "foo")) | ||||
| } | ||||
|  | ||||
| // https://github.com/docker/buildx/issues/1738 | ||||
| func testBakeRemoteContextSubdir(t *testing.T, sb integration.Sandbox) { | ||||
| 	bakefile := []byte(` | ||||
| target default { | ||||
| 	context = "./bar" | ||||
| } | ||||
| `) | ||||
| 	dockerfile := []byte(` | ||||
| FROM scratch | ||||
| COPY super-cool.txt / | ||||
| `) | ||||
|  | ||||
| 	dir := tmpdir( | ||||
| 		t, | ||||
| 		fstest.CreateFile("docker-bake.hcl", bakefile, 0600), | ||||
| 		fstest.CreateDir("bar", 0700), | ||||
| 		fstest.CreateFile("bar/Dockerfile", dockerfile, 0600), | ||||
| 		fstest.CreateFile("bar/super-cool.txt", []byte("super cool"), 0600), | ||||
| 	) | ||||
| 	dirDest := t.TempDir() | ||||
|  | ||||
| 	git, err := gitutil.New(gitutil.WithWorkingDir(dir)) | ||||
| 	require.NoError(t, err) | ||||
| 	gitutil.GitInit(git, t) | ||||
| 	gitutil.GitAdd(git, t, "docker-bake.hcl", "bar") | ||||
| 	gitutil.GitCommit(git, t, "initial commit") | ||||
| 	addr := gitutil.GitServeHTTP(git, t) | ||||
|  | ||||
| 	out, err := bakeCmd(sb, "/tmp", addr, "--set", "*.output=type=local,dest="+dirDest) | ||||
| 	require.NoError(t, err, out) | ||||
|  | ||||
| 	require.FileExists(t, filepath.Join(dirDest, "super-cool.txt")) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Justin Chadwell
					Justin Chadwell