From 8754d808326268e83176539050b032f978e5eae6 Mon Sep 17 00:00:00 2001 From: Jake Stewart Date: Sun, 3 Sep 2023 16:39:27 +0800 Subject: [PATCH] add tests for go config parser --- kittens/ssh/config_test.go | 18 ++++++++++++++++++ tools/config/api_test.go | 13 +++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/kittens/ssh/config_test.go b/kittens/ssh/config_test.go index 6d1e53514..62d596f57 100644 --- a/kittens/ssh/config_test.go +++ b/kittens/ssh/config_test.go @@ -47,6 +47,24 @@ func TestSSHConfigParsing(t *testing.T) { rt() conf = "env a=b" rt(`export 'a'="b"`) + + conf = "env a=\\" + rt(`export 'a'="\\"`) + conf = `env + \ a= + \\` + conf = "env\n \t \\ a=\n\\\\" + rt(`export 'a'="\\"`) + conf = ` + e + \n + \v + \ a + \= + \\ + \` + rt(`export 'a'="\\"`) + conf = "env a=b\nhostname 2\nenv a=c\nenv b=b" rt(`export 'a'="b"`) hostname = "2" diff --git a/tools/config/api_test.go b/tools/config/api_test.go index 223a57f3d..72ce23bbc 100644 --- a/tools/config/api_test.go +++ b/tools/config/api_test.go @@ -19,13 +19,18 @@ func TestConfigParsing(t *testing.T) { os.Mkdir(filepath.Join(tdir, "sub"), 0o700) os.WriteFile(conf_file, []byte( `error main -# ignore me +# igno + \re me a one #: other -include sub/b.conf +include +\ sub/b.conf b -include non-existent -globinclude sub/c?.conf +include non-exis +\tent +globin +\clude sub/c?.c + \onf `), 0o600) os.WriteFile(filepath.Join(tdir, "sub/b.conf"), []byte("incb cool\ninclude a.conf"), 0o600) os.WriteFile(filepath.Join(tdir, "sub/c1.conf"), []byte("inc1 cool"), 0o600)