summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorbep <bjorn.erik.pedersen@gmail.com>2015-03-12 20:50:44 +0100
committerbep <bjorn.erik.pedersen@gmail.com>2015-03-12 20:50:44 +0100
commitb190ad0ff9626f383945e137e66c0ae213f2c112 (patch)
tree26a6dbacd993faedc3f5faec96ad15311d33c1a4 /source
parentf8a840a14c9ad2ffa0120e9540be0a250409bfd3 (diff)
source: add some test cases for File
Diffstat (limited to 'source')
-rw-r--r--source/file_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/source/file_test.go b/source/file_test.go
new file mode 100644
index 000000000..6a4e456c6
--- /dev/null
+++ b/source/file_test.go
@@ -0,0 +1,25 @@
+package source
+
+import (
+ "github.com/spf13/hugo/helpers"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestFileUniqueID(t *testing.T) {
+ f1 := File{uniqueID: "123"}
+ f2 := NewFile("a")
+
+ assert.Equal(t, "123", f1.UniqueID())
+ assert.Equal(t, "0cc175b9c0f1b6a831c399e269772661", f2.UniqueID())
+}
+
+func TestFileString(t *testing.T) {
+ assert.Equal(t, "abc", NewFileWithContents("a", helpers.StringToReader("abc")).String())
+ assert.Equal(t, "", NewFile("a").String())
+}
+
+func TestFileBytes(t *testing.T) {
+ assert.Equal(t, []byte("abc"), NewFileWithContents("a", helpers.StringToReader("abc")).Bytes())
+ assert.Equal(t, []byte(""), NewFile("a").Bytes())
+}