From 6c52f843e001ce663cb744264d9a0ba8f8c20cdf Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Tue, 2 Jul 2019 13:25:29 -0500 Subject: [PATCH] Added additional test cases and fixed go test case --- client/allocdir/alloc_dir_test.go | 5 +++-- client/allocdir/input/test.bin | Bin 0 -> 1024 bytes client/allocdir/input/test.go | 25 +++++++++++++++++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 client/allocdir/input/test.bin diff --git a/client/allocdir/alloc_dir_test.go b/client/allocdir/alloc_dir_test.go index 451ae32e6cc..82b3ae1cb13 100644 --- a/client/allocdir/alloc_dir_test.go +++ b/client/allocdir/alloc_dir_test.go @@ -489,14 +489,15 @@ func TestAllocDir_DetectContentType(t *testing.T) { "input/happy.gif": "image/gif", "input/image.png": "image/png", "input/nomad.jpg": "image/jpeg", - "input/test.go": "application/octet-stream", + "input/test.bin": "application/octet-stream", "input/test.json": "application/json", "input/test.txt": "text/plain; charset=utf-8", + "input/test.go": "text/plain; charset=utf-8", } for _, file := range testFiles { fileInfo, err := os.Stat(file) require.Nil(err) res := detectContentType(fileInfo, file) - require.Equal(expectedEncodings[file], res) + require.Equal(expectedEncodings[file], res, "unexpected output for %v", file) } } diff --git a/client/allocdir/input/test.bin b/client/allocdir/input/test.bin new file mode 100644 index 0000000000000000000000000000000000000000..06d7405020018ddf3cacee90fd4af10487da3d20 GIT binary patch literal 1024 ScmZQz7zLvtFd70QH3R?z00031 literal 0 HcmV?d00001 diff --git a/client/allocdir/input/test.go b/client/allocdir/input/test.go index 8fd43ed1e52..fe29791c460 100644 --- a/client/allocdir/input/test.go +++ b/client/allocdir/input/test.go @@ -1,9 +1,26 @@ -package main +package allocdir import ( - "fmt" + "os" + "syscall" ) -func main() { - fmt.Println("Hello, playground") +// linkDir hardlinks src to dst. The src and dst must be on the same filesystem. +func linkDir(src, dst string) error { + return syscall.Link(src, dst) +} + +// unlinkDir removes a directory link. +func unlinkDir(dir string) error { + return syscall.Unlink(dir) +} + +// createSecretDir creates the secrets dir folder at the given path +func createSecretDir(dir string) error { + return os.MkdirAll(dir, 0777) +} + +// removeSecretDir removes the secrets dir folder +func removeSecretDir(dir string) error { + return os.RemoveAll(dir) }