mirror of
https://github.com/danog/gojekyll.git
synced 2024-11-26 23:24:39 +01:00
More coverage
This commit is contained in:
parent
ef85de3854
commit
ba1e46bcf5
12
helpers/pathname_test.go
Normal file
12
helpers/pathname_test.go
Normal file
@ -0,0 +1,12 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestTrimExt(t *testing.T) {
|
||||
require.Equal(t, "/a/b", TrimExt("/a/b.c"))
|
||||
require.Equal(t, "/a/b", TrimExt("/a/b"))
|
||||
}
|
34
helpers/yaml_test.go
Normal file
34
helpers/yaml_test.go
Normal file
@ -0,0 +1,34 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const mapYaml = "a: 1\nb: 2"
|
||||
const listYaml = "- a\n- b"
|
||||
|
||||
func TestUnmarshalYAML(t *testing.T) {
|
||||
var d interface{}
|
||||
err := UnmarshalYAMLInterface([]byte(mapYaml), &d)
|
||||
require.NoError(t, err)
|
||||
switch d := d.(type) {
|
||||
case map[interface{}]interface{}:
|
||||
require.Len(t, d, 2)
|
||||
require.Equal(t, 1, d["a"])
|
||||
default:
|
||||
require.IsType(t, d, map[interface{}]interface{}{})
|
||||
}
|
||||
|
||||
err = UnmarshalYAMLInterface([]byte(listYaml), &d)
|
||||
require.NoError(t, err)
|
||||
require.IsType(t, d, []interface{}{})
|
||||
switch d := d.(type) {
|
||||
case []interface{}:
|
||||
require.Len(t, d, 2)
|
||||
require.Equal(t, "a", d[0])
|
||||
default:
|
||||
require.IsType(t, d, map[interface{}]interface{}{})
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user