package recomapi import ( "fmt" "testing" "time" "videoweb/pub/common/log" ) var ( testUrl = "http://139.177.187.219:8087" testKey = "" ) func Test_InsertOneItem(t *testing.T) { itemInfo := &RSItemInfo{ Comment: "Comment1", ItemId: "10004", Labels: []string{"lable1", "lable2", "lable3"}, Timestamp: time.Now(), } serr := InsertOneItem(testUrl, testKey, itemInfo) fmt.Printf("\nTest_pingReq %s %v\n", itemInfo, serr) } func Test_InsertManyItems(t *testing.T) { list := make(RSItemInfoList, 0) itemInfo1 := &RSItemInfo{ Comment: "Comment1", ItemId: "10005", Labels: []string{"lable1", "lable2", "lable3"}, Timestamp: time.Now(), } list = append(list, itemInfo1) itemInfo2 := &RSItemInfo{ Comment: "Comment1", ItemId: "10006", Labels: []string{"lable1", "lable2", "lable3"}, Timestamp: time.Now(), } list = append(list, itemInfo2) serr := InsertManyItems(testUrl, testKey, list) fmt.Printf("\nTest_InsertManyItems %v\n", serr) } func Test_GetOneItem(t *testing.T) { itemInfo, serr := GetOneItem(testUrl, testKey, "10004") fmt.Printf("\nTest_GetOneItem %v %v\n", itemInfo, serr) } func Test_GetManyItem(t *testing.T) { itemInfos, cursor, serr := GetManyItems(testUrl, testKey, "10003", 2) log.Info("Test_GetManyItem", log.Any("itemInfos", itemInfos), log.Any("cursor", cursor), log.E(serr)) //fmt.Printf("\nTest_GetOneItem %v %v\n", itemInfos, serr) } func Test_DeleteOneItem(t *testing.T) { count, serr := DeleteOneItem(testUrl, testKey, "10004") log.Info("Test_DeleteOneItem", log.Any("count", count), log.E(serr)) //fmt.Printf("\nTest_GetOneItem %v %v\n", itemInfos, serr) } ////////////////////////////////////////////////////////////// //feedback func Test_AddOneFeedback(t *testing.T) { count, serr := AddOneFeedback(testUrl, testKey, 18531, 16346, FBT_Star, "feedback1") fmt.Printf("\nTest_pingReq %d %v\n", count, serr) } // /reccommend func Test_GetManyRecomItems(t *testing.T) { itemIds, serr := GetRecomItems(testUrl, testKey, 18531, "test", 10) log.Info("Test_GetManyRecomItems", log.Any("itemIds", itemIds), log.E(serr)) //fmt.Printf("\nTest_GetOneItem %v %v\n", itemInfos, serr) }