Updated TestReplaceExtensioni, TestFilename and TestFileAndExt - hugo - [fork] hugo port for 9front
 (HTM) git clone git@git.drkhsh.at/hugo.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 3521e8b1e57feb7ff9625a7e8bc453e10ba11b9e
 (DIR) parent 980d0f14de885122ed47482dde01228f7158015d
 (HTM) Author: Owen Waller <o.waller@kulawe.com>
       Date:   Mon, 22 Sep 2014 16:42:38 +0100
       
       Updated TestReplaceExtensioni, TestFilename and TestFileAndExt
       
       Updated the test cases in TestReplaceExtension to reflect the intent
       of ReplaceExtension which is to accept a path and return only the file
       name with a new extension. It's intentionally designed to strip out the
       path and only provide the filename
       
       Additional test cases have been added to both TestFilename and
       TestFileAndExt to clarify behaviour with relative paths.
       
       Diffstat:
         M helpers/path_test.go                |      37 ++++++++++++++++++++-----------
       
       1 file changed, 24 insertions(+), 13 deletions(-)
       ---
 (DIR) diff --git a/helpers/path_test.go b/helpers/path_test.go
       @@ -69,24 +69,27 @@ func TestMakeTitle(t *testing.T) {
                }
        }
        
       -//
       -// comment
       -//
       +// Replace Extension is probably poorly named, but the intent of the
       +// function is to accept a path and return only the file name with a
       +// new extension. It's intentionally designed to strip out the path
       +// and only provide the name. We should probably rename the function to
       +// be more explicit at some point.
        func TestReplaceExtension(t *testing.T) {
                type test struct {
                        input, newext, expected string
                }
                data := []test{
       -                // none of these work as you might expect
       -                {"/some/randome/path/file.xml", "html", "/some/randompath/file.html"},
       -                {"/banana.html", "HTML", "/banana.HTML"},
       -                {"./banana.html", "xml", "./banana.xml"},
       -                {"banana/pie/index.html", "xml", "banana/pie/index.xml"},
       -                {"../pies/fish/index.html", "xml", "../pies/fish/index.xml"},
       -                // but these all work even though they make no sense!
       -                {"/directory", "ext", "/directory.ext"},
       -                {"/directory/mydir/", "ext", "/directory/mydir/.ext"},
       -                {"mydir/", "ext", "mydir/.ext"},
       +                // These work according to the above defination
       +                {"/some/random/path/file.xml", "html", "file.html"},
       +                {"/banana.html", "xml", "banana.xml"},
       +                {"./banana.html", "xml", "banana.xml"},
       +                {"banana/pie/index.html", "xml", "index.xml"},
       +                {"../pies/fish/index.html", "xml", "index.xml"},
       +                // but these all fail
       +                {"filename-without-ext", ".ext", "filename-without-an-ext.ext"},
       +                {"/filename-without-an-ext", "ext", "filename-without-an-ext.ext"},
       +                {"/directory/mydir/", "ext", ".ext"},
       +                {"mydir/", "ext", ".ext"},
                }
        
                for i, d := range data {
       @@ -363,6 +366,10 @@ func TestFilename(t *testing.T) {
                        {"filename-no-ext", "filename-no-ext"},
                        {"directoy/", ""}, // no filename case??
                        {"directory/.hidden.ext", ".hidden"},
       +                {"./directory/../~/banana/gold.fish", "gold"},
       +                {"../directory/banana.man", "banana"},
       +                {"~/mydir/filename.ext", "filename"},
       +                {"./directory//tmp/filename.ext", "filename"},
                }
        
                for i, d := range data {
       @@ -388,6 +395,10 @@ func TestFileAndExt(t *testing.T) {
                        {"filename-no-ext", "filename-no-ext", ""},
                        {"directoy/", "", ""}, // no filename case??
                        {"directory/.hidden.ext", ".hidden", ".ext"},
       +                {"./directory/../~/banana/gold.fish", "gold", ".fish"},
       +                {"../directory/banana.man", "banana", ".man"},
       +                {"~/mydir/filename.ext", "filename", ".ext"},
       +                {"./directory//tmp/filename.ext", "filename", ".ext"},
                }
        
                for i, d := range data {