Merge pull request #5913 from hashicorp/f-fix-contenttype-tests

Fixed test case for detecting content type
This commit is contained in:
Preetha 2019-07-02 14:41:22 -05:00 committed by GitHub
commit 702072e5aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 6 deletions

View File

@ -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)
}
}

BIN
client/allocdir/input/test.bin (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -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)
}