github.com/royge/pop@v4.13.1+incompatible/columns/writeable_columns_test.go (about)

     1  package columns_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/gobuffalo/pop/columns"
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func Test_Columns_WriteableString_Symbolized(t *testing.T) {
    11  	r := require.New(t)
    12  	for _, f := range []interface{}{foo{}, &foo{}} {
    13  		c := columns.ForStruct(f, "foo")
    14  		u := c.Writeable().SymbolizedString()
    15  		r.Equal(u, ":LastName, :write")
    16  	}
    17  }
    18  
    19  func Test_Columns_UpdateString(t *testing.T) {
    20  	r := require.New(t)
    21  	for _, f := range []interface{}{foo{}, &foo{}} {
    22  		c := columns.ForStruct(f, "foo")
    23  		u := c.Writeable().UpdateString()
    24  		r.Equal(u, "LastName = :LastName, write = :write")
    25  	}
    26  }
    27  
    28  type testQuoter struct{}
    29  
    30  func (testQuoter) Quote(col string) string {
    31  	return `"` + col + `"`
    32  }
    33  
    34  func Test_Columns_QuotedUpdateString(t *testing.T) {
    35  	r := require.New(t)
    36  	q := testQuoter{}
    37  	for _, f := range []interface{}{foo{}, &foo{}} {
    38  		c := columns.ForStruct(f, "foo")
    39  		u := c.Writeable().QuotedUpdateString(q)
    40  		r.Equal(u, "\"LastName\" = :LastName, \"write\" = :write")
    41  	}
    42  }
    43  
    44  func Test_Columns_WriteableString(t *testing.T) {
    45  	r := require.New(t)
    46  	for _, f := range []interface{}{foo{}, &foo{}} {
    47  		c := columns.ForStruct(f, "foo")
    48  		u := c.Writeable().String()
    49  		r.Equal(u, "LastName, write")
    50  	}
    51  }