Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbep <bjorn.erik.pedersen@gmail.com>2015-01-20 19:44:35 +0300
committerbep <bjorn.erik.pedersen@gmail.com>2015-01-20 20:13:47 +0300
commit9e688507a792ceb4f5dacb0c9ccae621fb2ff804 (patch)
tree13d946642d1103da99270687151cc8217b178edc /helpers
parent1b91fec0ac28eac8dde6a7431bab7b11f286bdce (diff)
Add more tests to general helper
Diffstat (limited to 'helpers')
-rw-r--r--helpers/general_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/helpers/general_test.go b/helpers/general_test.go
index 687a56b4d..fef073f05 100644
--- a/helpers/general_test.go
+++ b/helpers/general_test.go
@@ -1,10 +1,52 @@
package helpers
import (
+ "github.com/stretchr/testify/assert"
"strings"
"testing"
)
+func TestGuessType(t *testing.T) {
+ for i, this := range []struct {
+ in string
+ expect string
+ }{
+ {"md", "markdown"},
+ {"markdown", "markdown"},
+ {"mdown", "markdown"},
+ {"rst", "rst"},
+ {"html", "html"},
+ {"htm", "html"},
+ {"excel", "unknown"},
+ } {
+ result := GuessType(this.in)
+ if result != this.expect {
+ t.Errorf("[%d] GuessType guessed wrong, expected %s, got %s", i, this.expect, result)
+ }
+ }
+}
+
+func TestBytesToReader(t *testing.T) {
+ asBytes := ReaderToBytes(strings.NewReader("Hello World!"))
+ asReader := BytesToReader(asBytes)
+ assert.Equal(t, []byte("Hello World!"), asBytes)
+ assert.Equal(t, asBytes, ReaderToBytes(asReader))
+}
+
+func TestStringToReader(t *testing.T) {
+ asString := ReaderToString(strings.NewReader("Hello World!"))
+ assert.Equal(t, "Hello World!", asString)
+ asReader := StringToReader(asString)
+ assert.Equal(t, asString, ReaderToString(asReader))
+}
+
+func TestFindAvailablePort(t *testing.T) {
+ addr, err := FindAvailablePort()
+ assert.Nil(t, err)
+ assert.NotNil(t, addr)
+ assert.True(t, addr.Port > 0)
+}
+
func TestInStringArrayCaseSensitive(t *testing.T) {
type test struct {
input string