...

Source file src/github.com/gobuffalo/flect/name/param_id_test.go

Documentation: github.com/gobuffalo/flect/name

     1  package name
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  )
     8  
     9  func Test_ParamID(t *testing.T) {
    10  	table := []tt{
    11  		{"foo_bar", "foo_bar_id"},
    12  		{"admin/widget", "admin_widget_id"},
    13  		{"admin/widgets", "admin_widget_id"},
    14  		{"widget", "widget_id"},
    15  		{"User", "user_id"},
    16  		{"user", "user_id"},
    17  		{"UserID", "user_id"},
    18  	}
    19  
    20  	for _, tt := range table {
    21  		t.Run(tt.act, func(st *testing.T) {
    22  			r := require.New(st)
    23  			r.Equal(tt.exp, ParamID(tt.act))
    24  			r.Equal(tt.exp, ParamID(tt.exp))
    25  		})
    26  	}
    27  }
    28  

View as plain text