From 1af6ffb9bb5a1dec665a56b1bdf621fd2e2b7377 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Tue, 26 Nov 2013 00:07:59 -0700 Subject: [PATCH] Add explicit test strings for new escapeFstabSpaces function --- lxc_template_unit_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lxc_template_unit_test.go b/lxc_template_unit_test.go index ce5af1d321..ccdfec8890 100644 --- a/lxc_template_unit_test.go +++ b/lxc_template_unit_test.go @@ -100,3 +100,21 @@ func grepFile(t *testing.T, path string, pattern string) { } t.Fatalf("grepFile: pattern \"%s\" not found in \"%s\"", pattern, path) } + +func TestEscapeFstabSpaces(t *testing.T) { + var testInputs = map[string]string{ + " ": "\\040", + "": "", + "/double space": "/double\\040\\040space", + "/some long test string": "/some\\040long\\040test\\040string", + "/var/lib/docker": "/var/lib/docker", + " leading": "\\040leading", + "trailing ": "trailing\\040", + } + for in, exp := range testInputs { + if out := escapeFstabSpaces(in); exp != out { + t.Logf("Expected %s got %s", exp, out) + t.Fail() + } + } +}