diff --git a/e2etests-cli/main_test.go b/e2etests-cli/main_test.go index 1718566f8..e5b3e5852 100644 --- a/e2etests-cli/main_test.go +++ b/e2etests-cli/main_test.go @@ -20,12 +20,22 @@ func TestCLI_E2E(t *testing.T) { run func(t *testing.T, ctx context.Context, dir string, env *xos.Env) }{ { - name: "hello_world", + name: "hello_world_png", run: func(t *testing.T, ctx context.Context, dir string, env *xos.Env) { - assert.WriteFile(t, filepath.Join(dir, "hello-world.d2"), []byte(`x -> y`), 0644) - err := runTestMain(t, ctx, dir, env, "hello-world.d2", "hello-world.png") + writeFile(t, dir, "hello-world.d2", `x -> y`) + err := runTestMain(t, ctx, dir, env, "hello-world.d2", "hello-world.png") assert.Success(t, err) - png := assert.ReadFile(t, filepath.Join(dir, "hello-world.png")) + png := readFile(t, dir, "hello-world.png") + assert.Testdata(t, ".png", png) + }, + }, + { + name: "hello_world_png_pad", + run: func(t *testing.T, ctx context.Context, dir string, env *xos.Env) { + writeFile(t, dir, "hello-world.d2", `x -> y`) + err := runTestMain(t, ctx, dir, env, "-pad 4000", "hello-world.d2", "hello-world.png") + assert.Success(t, err) + png := readFile(t, dir, "hello-world.png") assert.Testdata(t, ".png", png) }, }, @@ -67,3 +77,13 @@ func runTestMain(tb testing.TB, ctx context.Context, dir string, env *xos.Env, a defer tms.Cleanup(tb) return tms.Wait(ctx) } + +func writeFile(tb testing.TB, dir, fp, data string) { + tb.Helper() + assert.WriteFile(tb, filepath.Join(dir, fp), []byte(data), 0644) +} + +func readFile(tb testing.TB, dir, fp string) []byte { + tb.Helper() + return assert.ReadFile(tb, filepath.Join(dir, fp)) +} diff --git a/e2etests-cli/testdata/TestCLI_E2E/hello_world.exp.png b/e2etests-cli/testdata/TestCLI_E2E/hello_world.exp.png deleted file mode 100644 index 45c9386f9..000000000 Binary files a/e2etests-cli/testdata/TestCLI_E2E/hello_world.exp.png and /dev/null differ diff --git a/e2etests-cli/testdata/TestCLI_E2E/hello_world_png.exp.png b/e2etests-cli/testdata/TestCLI_E2E/hello_world_png.exp.png new file mode 100644 index 000000000..613ca9a63 Binary files /dev/null and b/e2etests-cli/testdata/TestCLI_E2E/hello_world_png.exp.png differ diff --git a/e2etests-cli/testdata/TestCLI_E2E/hello_world_png_pad.exp.png b/e2etests-cli/testdata/TestCLI_E2E/hello_world_png_pad.exp.png new file mode 100644 index 000000000..613ca9a63 Binary files /dev/null and b/e2etests-cli/testdata/TestCLI_E2E/hello_world_png_pad.exp.png differ diff --git a/go.sum b/go.sum index 1a687a2ae..d8c5c9272 100644 --- a/go.sum +++ b/go.sum @@ -277,8 +277,6 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -oss.terrastruct.com/util-go v0.0.0-20230301015829-35b30391c74d h1:+1Bp2bYA7bieedJuqbiwOLhnMs6GQQLB4sNX7BcDbSQ= -oss.terrastruct.com/util-go v0.0.0-20230301015829-35b30391c74d/go.mod h1:Fwy72FDIOOM4K8F96ScXkxHHppR1CPfUyo9+x9c1PBU= oss.terrastruct.com/util-go v0.0.0-20230303033840-484c630faa46 h1:pVcaRgqhNDXtWlsHg1cAy7BRycDiOaAEBexCFgMyUxQ= oss.terrastruct.com/util-go v0.0.0-20230303033840-484c630faa46/go.mod h1:Fwy72FDIOOM4K8F96ScXkxHHppR1CPfUyo9+x9c1PBU= rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4=