From 015113d56dd76c5e1cab3a4047e933bb06226978 Mon Sep 17 00:00:00 2001 From: Aleksey Lobanov Date: Tue, 29 Mar 2016 00:44:47 +0300 Subject: [PATCH] Added tests for GetFileType --- src/main.go | 2 +- src/main_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main.go b/src/main.go index 54e8607..65f11ea 100644 --- a/src/main.go +++ b/src/main.go @@ -237,7 +237,7 @@ func GetStatTimesFromDb(db *sql.DB, fromTime int64, keyMap map[uint8]string) []S } func GetFileType(path string) string { - + return "" } func main() { diff --git a/src/main_test.go b/src/main_test.go index 5086f3e..8dca16f 100644 --- a/src/main_test.go +++ b/src/main_test.go @@ -59,3 +59,28 @@ func TestGetKeyNumsFromOutput(t *testing.T) { t.Fail() } } + +func TestGetFileType(t *testing.T) { + tests := map[string]string{ + "": "", + "out.csv": "csv", + "out.jsl": "jsl", + "out.json": "json", + "//sfd.dsf//.f./out.out.csv": "csv", + "..\\data.all.jsl.gz": "jsl.gz", + "../full.csv/first.data.json": "json", + "//sfd.dsf//.f./WhiteBear.csv.Gz": "csv.gz", + "out.JsL": "jsl", + "////////": "", + "\\\\\\": "", + "file1.Json.gz": "json.gz", + "out.csv.json.jsl": "jsl", + "out.jsl.json.csv": "csv", + } + for test, res := range tests { + if GetFileType(test) != res { + t.Log("On test ", test, " result is ", GetFileType(test), " but right is ", res, "") + } + t.Fail() + } +}