当前位置: 首页>>代码示例>>Golang>>正文


Golang TableWebsiteSlice.Len方法代码示例

本文整理汇总了Golang中github.com/corestoreio/csfw/store.TableWebsiteSlice.Len方法的典型用法代码示例。如果您正苦于以下问题:Golang TableWebsiteSlice.Len方法的具体用法?Golang TableWebsiteSlice.Len怎么用?Golang TableWebsiteSlice.Len使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/corestoreio/csfw/store.TableWebsiteSlice的用法示例。


在下文中一共展示了TableWebsiteSlice.Len方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestTableWebsiteSlice

func TestTableWebsiteSlice(t *testing.T) {
	websites := store.TableWebsiteSlice{
		&store.TableWebsite{WebsiteID: 0, Code: dbr.NewNullString("admin"), Name: dbr.NewNullString("Admin"), SortOrder: 0, DefaultGroupID: 0, IsDefault: dbr.NewNullBool(false)},
		&store.TableWebsite{WebsiteID: 1, Code: dbr.NewNullString("euro"), Name: dbr.NewNullString("Europe"), SortOrder: 0, DefaultGroupID: 1, IsDefault: dbr.NewNullBool(true)},
		nil,
		&store.TableWebsite{WebsiteID: 2, Code: dbr.NewNullString("oz"), Name: dbr.NewNullString("OZ"), SortOrder: 20, DefaultGroupID: 3, IsDefault: dbr.NewNullBool(false)},
	}
	assert.True(t, websites.Len() == 4)

	w1, err := websites.FindByWebsiteID(999)
	assert.Nil(t, w1)
	assert.EqualError(t, store.ErrIDNotFoundTableWebsiteSlice, err.Error())

	w2, err := websites.FindByWebsiteID(2)
	assert.NotNil(t, w2)
	assert.NoError(t, err)
	assert.Equal(t, int64(2), w2.WebsiteID)

	w3, err := websites.FindByCode("euro")
	assert.NotNil(t, w3)
	assert.NoError(t, err)
	assert.Equal(t, "euro", w3.Code.String)

	w4, err := websites.FindByCode("corestore")
	assert.Nil(t, w4)
	assert.EqualError(t, store.ErrIDNotFoundTableWebsiteSlice, err.Error())

	wf1 := websites.Filter(func(w *store.TableWebsite) bool {
		return w != nil && w.WebsiteID == 1
	})
	assert.EqualValues(t, "Europe", wf1[0].Name.String)
}
开发者ID:levcom,项目名称:csfw,代码行数:32,代码来源:website_test.go

示例2: TestTableWebsiteSlice

func TestTableWebsiteSlice(t *testing.T) {
	websites := store.TableWebsiteSlice{
		&store.TableWebsite{WebsiteID: 0, Code: dbr.NullString{NullString: sql.NullString{String: "admin", Valid: true}}, Name: dbr.NullString{NullString: sql.NullString{String: "Admin", Valid: true}}, SortOrder: 0, DefaultGroupID: 0, IsDefault: dbr.NullBool{NullBool: sql.NullBool{Bool: false, Valid: true}}},
		&store.TableWebsite{WebsiteID: 1, Code: dbr.NullString{NullString: sql.NullString{String: "euro", Valid: true}}, Name: dbr.NullString{NullString: sql.NullString{String: "Europe", Valid: true}}, SortOrder: 0, DefaultGroupID: 1, IsDefault: dbr.NullBool{NullBool: sql.NullBool{Bool: true, Valid: true}}},
		nil,
		&store.TableWebsite{WebsiteID: 2, Code: dbr.NullString{NullString: sql.NullString{String: "oz", Valid: true}}, Name: dbr.NullString{NullString: sql.NullString{String: "OZ", Valid: true}}, SortOrder: 20, DefaultGroupID: 3, IsDefault: dbr.NullBool{NullBool: sql.NullBool{Bool: false, Valid: true}}},
	}
	assert.True(t, websites.Len() == 4)

	w1, err := websites.FindByID(999)
	assert.Nil(t, w1)
	assert.EqualError(t, store.ErrWebsiteNotFound, err.Error())

	w2, err := websites.FindByID(2)
	assert.NotNil(t, w2)
	assert.NoError(t, err)
	assert.Equal(t, int64(2), w2.WebsiteID)

	w3, err := websites.FindByCode("euro")
	assert.NotNil(t, w3)
	assert.NoError(t, err)
	assert.Equal(t, "euro", w3.Code.String)

	w4, err := websites.FindByCode("corestore")
	assert.Nil(t, w4)
	assert.EqualError(t, store.ErrWebsiteNotFound, err.Error())

	wf1 := websites.Filter(func(w *store.TableWebsite) bool {
		return w.WebsiteID == 1
	})
	assert.EqualValues(t, "Europe", wf1[0].Name.String)
}
开发者ID:postfix,项目名称:csfw,代码行数:32,代码来源:website_test.go

示例3: TestTableWebsiteSliceLoad

func TestTableWebsiteSliceLoad(t *testing.T) {
	db := csdb.MustConnectTest()
	defer db.Close()
	dbrSess := dbr.NewConnection(db, nil).NewSession(nil)
	var websites store.TableWebsiteSlice
	websites.Load(dbrSess)
	assert.True(t, websites.Len() > 2)
	for _, s := range websites {
		assert.True(t, len(s.Code.String) > 1)
	}
}
开发者ID:bom-d-van,项目名称:csfw,代码行数:11,代码来源:website_test.go

示例4: TestTableWebsiteSliceLoad

func TestTableWebsiteSliceLoad(t *testing.T) {
	dbc := csdb.MustConnectTest()
	defer dbc.Close()
	dbrSess := dbc.NewSession()

	var websites store.TableWebsiteSlice
	websites.SQLSelect(dbrSess)
	assert.True(t, websites.Len() >= 2)
	for _, s := range websites {
		assert.True(t, len(s.Code.String) > 1)
	}
}
开发者ID:hafeez3000,项目名称:csfw,代码行数:12,代码来源:website_test.go


注:本文中的github.com/corestoreio/csfw/store.TableWebsiteSlice.Len方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。