From e88e243d4c1f773af243bd54489fb2fe84426d04 Mon Sep 17 00:00:00 2001 From: Nathan Sarang-Walters Date: Mon, 16 Dec 2024 15:29:21 -0800 Subject: [PATCH] Add E2E test --- e2etests-cli/main_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/e2etests-cli/main_test.go b/e2etests-cli/main_test.go index 432d59aff..ff764ac5e 100644 --- a/e2etests-cli/main_test.go +++ b/e2etests-cli/main_test.go @@ -1005,6 +1005,19 @@ layers: { assert.Equal(t, "x -> y\n", string(gotBar)) }, }, + { + name: "fmt-check", + run: func(t *testing.T, ctx context.Context, dir string, env *xos.Env) { + writeFile(t, dir, "foo.d2", `a ---> b`) + writeFile(t, dir, "bar.d2", `x ---> y`) + err := runTestMainPersist(t, ctx, dir, env, "fmt", "--check", "foo.d2", "bar.d2") + assert.ErrorString(t, err, "failed to wait xmain test: e2etests-cli/d2: failed to fmt: exiting with code 1: found 2 unformatted files. Run d2 fmt to fix.") + gotFoo := readFile(t, dir, "foo.d2") + gotBar := readFile(t, dir, "bar.d2") + assert.Equal(t, "a ---> b", string(gotFoo)) + assert.Equal(t, "x ---> y", string(gotBar)) + }, + }, { name: "watch-regular", serial: true,