diff --git a/htmltest/options.go b/htmltest/options.go
index a38c880..e497cf7 100644
--- a/htmltest/options.go
+++ b/htmltest/options.go
@@ -2,12 +2,13 @@ package htmltest
import (
"fmt"
- "github.com/imdario/mergo"
- "github.com/wjdp/htmltest/issues"
"path"
"reflect"
"regexp"
"strings"
+
+ "github.com/imdario/mergo"
+ "github.com/wjdp/htmltest/issues"
)
// Options struct for htmltest, user and default options are merged and mapped
@@ -113,7 +114,7 @@ func DefaultOptions() map[string]interface{} {
"IgnoreSSLVerify": false,
"IgnoreTagAttribute": "data-proofer-ignore",
- "HTTPHeaders": map[string]string{
+ "HTTPHeaders": map[interface{}]interface{}{
"Range": "bytes=0-0", // If server supports prevents body being sent
"Accept": "*/*", // We accept all content types
},
@@ -145,9 +146,9 @@ func DefaultOptions() map[string]interface{} {
func (hT *HTMLTest) setOptions(optsUser map[string]interface{}) {
// Merge user and default options, set Opts var
optsMap := DefaultOptions()
- mergo.MergeWithOverwrite(&optsMap, optsUser)
+ mergo.Merge(&optsMap, optsUser, mergo.WithOverride)
hT.opts = Options{}
- mergo.MapWithOverwrite(&hT.opts, optsMap)
+ mergo.Map(&hT.opts, optsMap, mergo.WithOverride)
// If debug dump the options struct
if hT.opts.LogLevel == issues.LevelDebug {
diff --git a/htmltest/options_test.go b/htmltest/options_test.go
index 95fc451..2cc4da5 100644
--- a/htmltest/options_test.go
+++ b/htmltest/options_test.go
@@ -1,9 +1,10 @@
package htmltest
import (
+ "testing"
+
"github.com/daviddengcn/go-assert"
"github.com/wjdp/htmltest/output"
- "testing"
)
func TestDefaultOptions(t *testing.T) {
@@ -57,3 +58,18 @@ func TestIsURLIgnored(t *testing.T) {
assert.IsFalse(t, "url left alone", hT.opts.isURLIgnored("https://froogle.com/?q=1234"))
assert.IsFalse(t, "url left alone", hT.opts.isURLIgnored("http://assetstore.info/lib/test.js"))
}
+
+func TestMergeHTTPHeaders(t *testing.T) {
+ userOpts := map[string]interface{}{
+ "HTTPHeaders": map[interface{}]interface{}{
+ "Range": "bytes=0-10",
+ "Accept": "*/*",
+ },
+ "NoRun": true,
+ }
+
+ hT, err := Test(userOpts)
+ output.CheckErrorPanic(err)
+
+ assert.Equals(t, "url ignored", hT.opts.HTTPHeaders["Range"], "bytes=0-10")
+}