Exemple #1
0
func TestFileType(t *testing.T) {
	t.Parallel()
	if util.GetFileType("hello.pptx") != "pptx" {
		t.Fatal("GetFileType can't get a simple file type.")
	}

	if util.GetFileType("hello.pptx.tar.gz") != "gz" {
		t.Fatal("GetFileType can't get the last file type.")
	}

	if util.GetFileType("README") != "" {
		t.Fatal("GetFile gets a file extension when there is none.")
	}
}
Exemple #2
0
//Searches a list of file names for the file with
//a given extension and returns its name.
func getFileWithType(ft string, fns []string) string {
	for _, fn := range fns {
		if util.GetFileType(fn) == ft {
			return fn
		}
	}
	return ""
}