<commit_before>package conjungo

import (
	"encoding/json"
	"errors"
	"reflect"
	"time"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/ginkgo/extensions/table"
	. "github.com/onsi/gomega"
)

var _ = Describe("Options", func() {
	var (
		testOpts *Options
	)
	Context("happy path", func() {
		BeforeEach(func() {
			testOpts = NewOptions()
		})

		It("not nil", func() {
			Expect(testOpts).ToNot(BeNil())
		})

		It("defailts to overwrite true", func() {
			Expect(testOpts.Overwrite).To(BeTrue())
		})

		It("sets up mergefuncs", func() {
			Expect(testOpts.mergeFuncs).ToNot(BeNil())
		})
	})
})

var _ = Describe("Merge", func() {
	type Foo struct {
		Name    string
		Size    int
		Special bool
		Tags    []interface{}
	}

	var (
		targetMap, sourceMap map[string]interface{}
	)
<commit_msg>cover new set funcs<commit_after>package conjungo

import (
	"encoding/json"
	"errors"
	"reflect"
	"time"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/ginkgo/extensions/table"
	. "github.com/onsi/gomega"
)

var _ = Describe("Options", func() {
	var (
		testOpts *Options
	)
	Context("happy path", func() {
		BeforeEach(func() {
			testOpts = NewOptions()
		})

		It("not nil", func() {
			Expect(testOpts).ToNot(BeNil())
		})

		It("defailts to overwrite true", func() {
			Expect(testOpts.Overwrite).To(BeTrue())
		})

		It("sets up mergefuncs", func() {
			Expect(testOpts.mergeFuncs).ToNot(BeNil())
		})
	})

	Context("set merge funcs", func() {
		var (
			opt *Options
			mf  MergeFunc
		)

		BeforeEach(func() {
			opt = NewOptions()
			mf = func(t, s reflect.Value, o *Options) (reflect.Value, error) {
				return reflect.Value{}, errors.New("special error")
			}
		})

		It("SetTypeMergeFunc sets func", func() {
			t := reflect.TypeOf("")
			opt.SetTypeMergeFunc(t, mf)

			_, err := opt.mergeFuncs.typeFuncs[t](reflect.Value{}, reflect.Value{}, nil)
			Expect(err.Error()).To(Equal("special error"))
		})

		It("SetKindMergeFunc sets func", func() {
			k := reflect.ValueOf("").Kind()
			opt.SetKindMergeFunc(k, mf)

			_, err := opt.mergeFuncs.kindFuncs[k](reflect.Value{}, reflect.Value{}, nil)
			Expect(err.Error()).To(Equal("special error"))
		})

		It("SetDefaultMergeFunc sets func", func() {
			opt.SetDefaultMergeFunc(mf)

			_, err := opt.mergeFuncs.defaultFunc(reflect.Value{}, reflect.Value{}, nil)
			Expect(err.Error()).To(Equal("special error"))
		})
	})
})

var _ = Describe("Merge", func() {
	type Foo struct {
		Name    string
		Size    int
		Special bool
		Tags    []interface{}
	}

	var (
		targetMap, sourceMap map[string]interface{}
	)

{'fraction_non_alphanumeric': 0.17718068535825546, 'fraction_numerical': 0.0, 'mean_word_length': 3.637184115523466, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '709661', 'n_tokens_mistral': 1049, 'n_tokens_neox': 948, 'n_words': 176}