mirror of https://github.com/nmasse-itix/liche.git
7 changed files with 123 additions and 1 deletions
@ -0,0 +1,14 @@ |
|||||
|
package main |
||||
|
|
||||
|
import "path/filepath" |
||||
|
|
||||
|
var extensions = map[string]bool{ |
||||
|
".htm": true, |
||||
|
".html": true, |
||||
|
".md": true, |
||||
|
} |
||||
|
|
||||
|
func isMarkupFile(f string) bool { |
||||
|
_, ok := extensions[filepath.Ext(f)] |
||||
|
return ok |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
package main |
||||
|
|
||||
|
import ( |
||||
|
"testing" |
||||
|
|
||||
|
"github.com/stretchr/testify/assert" |
||||
|
) |
||||
|
|
||||
|
func TestIsMarkupFile(t *testing.T) { |
||||
|
for _, f := range []string{"foo.md", "foo.html", "foo.htm", "foo/bar.md"} { |
||||
|
assert.True(t, isMarkupFile(f)) |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
package main |
||||
|
|
||||
|
import ( |
||||
|
"os" |
||||
|
"testing" |
||||
|
|
||||
|
"github.com/stretchr/testify/assert" |
||||
|
) |
||||
|
|
||||
|
func TestListFiles(t *testing.T) { |
||||
|
fs := listFiles(".") |
||||
|
|
||||
|
assert.NotEqual(t, 0, len(fs)) |
||||
|
|
||||
|
for _, f := range fs { |
||||
|
i, err := os.Stat(f) |
||||
|
|
||||
|
assert.True(t, isMarkupFile(f)) |
||||
|
assert.Equal(t, nil, err) |
||||
|
assert.False(t, i.IsDir()) |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue