github.com/RevenueMonster/sqlike@v1.0.6/sqlike/options/insert_test.go (about)

     1  package options
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  )
     8  
     9  func TestInsertOptions(t *testing.T) {
    10  	opt := Insert()
    11  
    12  	t.Run("SetDebug", func(it *testing.T) {
    13  		{
    14  			opt.SetDebug(true)
    15  			require.True(it, opt.Debug)
    16  		}
    17  
    18  		{
    19  			opt.SetDebug(false)
    20  			require.False(it, opt.Debug)
    21  		}
    22  	})
    23  
    24  	t.Run("SetMode", func(it *testing.T) {
    25  		{
    26  			opt.SetMode(InsertIgnore)
    27  			require.Equal(it, InsertIgnore, opt.Mode)
    28  		}
    29  
    30  		{
    31  			opt.SetMode(InsertOnDuplicate)
    32  			require.Equal(it, InsertOnDuplicate, opt.Mode)
    33  		}
    34  
    35  		// default insert mode
    36  		{
    37  			ot := Insert()
    38  			require.Equal(it, insertMode(0), ot.Mode)
    39  		}
    40  	})
    41  
    42  	t.Run("SetOmitFields", func(it *testing.T) {
    43  		opt.SetOmitFields("test", "__c__")
    44  		require.ElementsMatch(it, []string{"test", "__c__"}, opt.Omits)
    45  	})
    46  
    47  }