本文整理匯總了Golang中mws/util.GetCallerName函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetCallerName函數的具體用法?Golang GetCallerName怎麽用?Golang GetCallerName使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetCallerName函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestTagModelUpdateStatus
func TestTagModelUpdateStatus(t *testing.T) {
funcName := util.GetCallerName()
log.Printf("%s ---------------- Starting Test ---------------------", funcName)
TestTagModelCreate(t)
log.SetPrefix(util.GetCallerName() + " : ")
smodel := TagModel{}
operation, _ := GetVDLOperation(smodel, "updatestatus")
tag_id := int64(tagId)
gotTag, retCode, err := smodel.UpdateStatus(operation, tag_id, dto.BANNED)
if err != nil {
log.Fatalf("%s Failed: %#v", funcName, err)
count.FailCount++
return
}
if got, want := retCode, 0; got != want {
t.Errorf("%s got %d, wanted %d", funcName, got, want)
count.FailCount++
return
}
tagId = (*gotTag).Id
log.Printf("%s Successful for %#v", funcName, gotTag)
count.SuccessCount++
log.SetPrefix("")
}
示例2: TestUserModelDelete
func TestUserModelDelete(t *testing.T) {
funcName := util.GetCallerName()
log.Printf("%s ---------------- Starting Test ---------------------", funcName)
TestUserModelCreate(t)
log.SetPrefix(util.GetCallerName() + " : ")
umodel := UserModel{}
operation, _ := GetVDLOperation(umodel, "delete")
user_id := int64(userId)
gotUser, retCode, err := umodel.Delete(operation, user_id)
if err != nil {
log.Fatalf("%s Failed: %#v", funcName, err)
count.FailCount++
return
}
if got, want := retCode, 0; got != want {
t.Errorf("%s got %d, wanted %d", funcName, got, want)
count.FailCount++
return
}
userId = (*gotUser).Id
log.Printf("%s Successful for %#v", funcName, gotUser)
count.SuccessCount++
log.SetPrefix("")
}
示例3: TestTagModelCreate
func TestTagModelCreate(t *testing.T) {
funcName := util.GetCallerName()
log.Printf("%s ---------------- Starting Test ---------------------", funcName)
log.SetPrefix(util.GetCallerName() + " : ")
getThisTag := dto.Tag{
Name: "test tag",
Description: "Content for my first tag <b>has tags</b>",
Status: dto.SetStatus(dto.INITIALIZED),
}
smodel := TagModel{}
operation, _ := GetVDLOperation(smodel, "create")
gotTag, retCode, err := smodel.Create(operation, &getThisTag)
if err != nil {
log.Fatalf("%s Failed: %#v", funcName, err)
count.FailCount++
return
}
if got, want := retCode, 0; got != want {
t.Errorf("%s got %d, wanted %d", funcName, got, want)
count.FailCount++
return
}
tagId = (*gotTag).Id
log.Printf("%s Successful for %#v", funcName, gotTag)
count.SuccessCount++
log.SetPrefix("")
}
示例4: TestUserModelCreate
func TestUserModelCreate(t *testing.T) {
funcName := util.GetCallerName()
log.Printf("%s ---------------- Starting Test ---------------------", funcName)
log.SetPrefix(util.GetCallerName() + " : ")
getThisUser := dto.User{
Name: "Rate My First User",
Email: "[email protected]",
//Status: dto.SetStatus(dto.INITIALIZED),
}
umodel := UserModel{}
operation, _ := GetVDLOperation(umodel, "create")
gotUser, retCode, err := umodel.Create(operation, &getThisUser)
if err != nil {
log.Fatalf("%s Failed: %#v", funcName, err)
count.FailCount++
return
}
if got, want := retCode, 0; got != want {
t.Errorf("%s got %d, wanted %d", funcName, got, want)
count.FailCount++
return
}
userId = (*gotUser).Id
log.Printf("%s Successful for %#v", funcName, gotUser)
count.SuccessCount++
log.SetPrefix("")
}
示例5: TestUserModelUpdate
func TestUserModelUpdate(t *testing.T) {
funcName := util.GetCallerName()
log.Printf("%s ---------------- Starting Test ---------------------", funcName)
TestUserModelCreate(t)
log.SetPrefix(util.GetCallerName() + " : ")
getThisUser := dto.User{
Email: "[email protected]",
Status: dto.SetStatus(dto.ACTIVE),
}
umodel := UserModel{}
operation, _ := GetVDLOperation(umodel, "update")
user_id := int64(userId)
gotUser, retCode, err := umodel.Update(operation, user_id, &getThisUser)
if err != nil {
log.Fatalf("%s Failed: %#v", funcName, err)
count.FailCount++
return
}
if got, want := retCode, 0; got != want {
t.Errorf("%s got %d, wanted %d", funcName, got, want)
count.FailCount++
return
}
userId = (*gotUser).Id
log.Printf("%s Successful for %#v", funcName, gotUser)
count.SuccessCount++
log.SetPrefix("")
}
示例6: TestTagModelFindById
func TestTagModelFindById(t *testing.T) {
funcName := util.GetCallerName()
log.Printf("%s ---------------- Starting Test ---------------------", funcName)
TestTagModelCreate(t)
log.SetPrefix(util.GetCallerName() + " : ")
smodel := TagModel{}
operation, _ := GetVDLOperation(smodel, "findbyid")
tag_id := int64(tagId)
gotSection, retCode, err := smodel.FindById(operation, tag_id)
if err != nil {
log.Fatalf("%s Failed: %#v", funcName, err)
count.FailCount++
return
}
if got, want := retCode, 0; got != want {
t.Errorf("%s got %d, wanted %d", funcName, got, want)
count.FailCount++
return
}
sectionId = (*gotSection).Id
log.Printf("%s Successful for %#v", funcName, gotSection)
count.SuccessCount++
log.SetPrefix("")
}
示例7: TestRevisionModelCreate
func TestRevisionModelCreate(t *testing.T) {
funcName := util.GetCallerName()
log.Printf("---------------- Starting Test ( %s )---------------------", funcName)
TestUserModelCreate(t)
TestSectionModelCreate(t)
log.SetPrefix(util.GetCallerName() + " : ")
getThisRevision := dto.Revision{
SectionId: sectionId,
Content: "Content for my first revision <b>has tags</b>",
}
smodel := RevisionModel{}
if gotRevision, retCode, err := smodel.Create("create_revision", userId, &getThisRevision); gotRevision == nil || err != nil {
//if gotRevision == nil || err != nil {
log.Fatalf(" RevisionModel Create Failed: %#v", err)
count.FailCount++
return
} else {
if got, want := retCode, 0; got != want {
t.Errorf("RevisionModelCreate Broken: got %d, wanted %d", got, want)
count.FailCount++
return
}
revId = (*gotRevision).Id
log.Printf("RevisionModel Create Successful for %#v", gotRevision)
count.SuccessCount++
}
log.SetPrefix("")
}
示例8: TestPageModelCreate
func TestPageModelCreate(t *testing.T) {
log.Printf("---------------- Starting Test ( %s )---------------------", util.GetCallerName())
TestUserModelCreate(t)
log.SetPrefix(util.GetCallerName() + " : ")
getThisPage := dto.Page{
Title: "Rate My First Page",
}
pmodel := PageModel{}
operation, _ := GetVDLOperation(pmodel, "create")
author_id := int64(userId)
gotPage, retCode, err := pmodel.Create(operation, author_id, &getThisPage)
if err != nil {
log.Fatalf(" PageModel Create Failed: %#v", err)
count.FailCount++
return
}
if got, want := retCode, 0; got != want {
t.Errorf("PageModelCreate Broken: got %d, wanted %d", got, want)
count.FailCount++
return
}
pageId = (*gotPage).Id
log.Printf("PageModel Create Successful for %#v", gotPage)
count.SuccessCount++
log.SetPrefix("")
}
示例9: TestSectionModelUpdate
func TestSectionModelUpdate(t *testing.T) {
funcName := util.GetCallerName()
log.Printf("%s ---------------- Starting Test ---------------------", funcName)
TestSectionModelCreate(t)
log.SetPrefix(util.GetCallerName() + " : ")
getThisSection := dto.Section{
Name: "Update My First Section",
PageId: pageId,
OrderNum: 1,
Status: dto.SetStatus(dto.ACTIVE),
}
smodel := SectionModel{}
operation, _ := GetVDLOperation(smodel, "update")
section_id := int64(sectionId)
gotSection, retCode, err := smodel.Update(operation, section_id, &getThisSection)
if err != nil {
log.Fatalf("%s Failed: %#v", funcName, err)
count.FailCount++
return
}
if got, want := retCode, 0; got != want {
t.Errorf("%s got %d, wanted %d", funcName, got, want)
count.FailCount++
return
}
sectionId = (*gotSection).Id
log.Printf("%s Successful for %#v", funcName, gotSection)
count.SuccessCount++
log.SetPrefix("")
}
示例10: TestRatingModelCreate
func TestRatingModelCreate(t *testing.T) {
testName := util.GetCallerName()
log.Printf("---------------- Starting Test ( %s )---------------------", testName)
TestUserModelCreate(t)
//userId := createId
TestRevisionModelCreate(t)
//revId := createId
trmodel := RatingModel{}
if gotER, retCode, err := trmodel.CreateRelationship("addrating", userId, revId, 100); gotER == nil || err != nil {
//if gotER == nil || err != nil {
log.Fatalf("%s Failed: %#v", testName, err)
count.FailCount++
return
} else {
if got, want := retCode, 0; got != want {
t.Errorf("%s Broken: got %d, wanted %d", testName, got, want)
count.FailCount++
return
}
// createId = (*gotER).Id
log.Printf("%s Create Successful for relationship (%d)", testName, gotER.AccountId)
count.SuccessCount++
return
}
}
示例11: processGenericVDL
func processGenericVDL(vdlOperation string, variadicArgs ...interface{}) ([]map[string]interface{}, int, error) {
funcName := util.GetCallerName()
if vdlOperation == "" {
return nil, -1, errors.New(fmt.Sprintf("%s: VDL annotation not set", funcName))
}
log.Printf("%s -- Calling operation %s with %v", funcName, vdlOperation, variadicArgs)
// Get the Postgres Function information
pgfunc, _ := pgreflect.GetPgFuncInfo(vdlOperation)
//
// Check the argument list size agrees
if pgfunc.NumArgs != len(variadicArgs) {
log.Printf("%s -- Error with number of argument for %s has %d, passing in %d", funcName, vdlOperation, pgfunc.NumArgs, len(variadicArgs))
return nil, -1, errors.New(fmt.Sprintf("Error with number of argument for %s has %d, passing in %d", vdlOperation, pgfunc.NumArgs, len(variadicArgs)))
}
//Call the function and get return values
retMap, retCode, err := pgfunc.VariadicScan(variadicArgs...)
if err != nil || retMap == nil || len(retMap) == 0 {
log.Printf("%s -- Error Calling Postgres Function - %s ( %#v)", funcName, pgfunc.Name, pgfunc)
return nil, -1, err
}
log.Printf("%s -- Postgres Function Returned- %#v, %d, %#v", funcName, retMap, retCode, err)
return retMap, retCode, nil
}
示例12: TestCreateUser
func TestCreateUser(t *testing.T) {
log.Printf("---------------- Starting Test ( %s )---------------------", util.GetCallerName())
//now := time.Now();
wantUserJSON := `{"Id":0,"Name":"sCamelCase","Email":"[email protected]","Status":{"StatusCode":0,"Desc":"Initalized"}}`
u := &User{
Name: "sCamelCase",
Email: "[email protected]",
Status: StatusDetail{INITIALIZED, fmt.Sprint(StatusType(INITIALIZED))},
}
//u.Created = &jsonTime{time.Now(), time.RFC3339}
//u.Modified = &jsonTime{time.Now(), time.RFC3339}
gotJSON, err := json.Marshal(u)
if err != nil {
t.Error(err)
return
}
//
if wantUserJSON != string(gotJSON) {
t.Errorf("Received = %s\n Expected %s", gotJSON, wantUserJSON)
return
}
log.Printf("Successfully created user %s", string(gotJSON))
}
示例13: TestEntityRelationShipNoExtraValues
func TestEntityRelationShipNoExtraValues(t *testing.T) {
funcName := util.GetCallerName()
log.Printf("%s ---------------- Starting Test ---------------------", funcName)
er := &EntityRelationship{
RelId1: 1,
RelId2: 1,
RelName1: "dto.Revision",
RelName2: "dto.Tag",
RelType1: reflect.TypeOf(Revision{}),
RelType2: reflect.TypeOf(Tag{}),
Status: SetStatus(StatusType(0)),
}
//
if er == nil || er.Values != nil || len(er.Values) != 0 {
t.Errorf("%s Values set = %v", funcName, er)
count.FailCount++
return
}
gotJSON, err := json.Marshal(er)
if err != nil {
t.Error("%s Could not construct JSON %v", funcName, err)
count.FailCount++
return
}
if hasValues := strings.Contains(string(gotJSON), "Values"); hasValues {
t.Error("%s Values still present in %v", funcName, string(gotJSON))
count.FailCount++
return
}
log.Printf("%s Successfully created entity relationship %v", funcName, string(gotJSON))
count.SuccessCount++
}
示例14: TestEntityRelationShipExtraValues
func TestEntityRelationShipExtraValues(t *testing.T) {
funcName := util.GetCallerName()
log.Printf("%s ---------------- Starting Test ---------------------", funcName)
er := &EntityRelationship{
RelId1: 1,
RelId2: 1,
RelName1: "dto.Revision",
RelName2: "dto.Tag",
RelType1: reflect.TypeOf(Revision{}),
RelType2: reflect.TypeOf(Tag{}),
Status: SetStatus(StatusType(0)),
Values: map[string]interface{}{"rating": 100, fmt.Sprintf("%s", reflect.TypeOf(Tag{})): Tag{Id: 1}},
}
//
if er == nil || er.Values == nil || len(er.Values) == 0 {
t.Errorf("%s Values not set = %v", funcName, er)
count.FailCount++
return
}
for k, v := range er.Values {
log.Printf("%s Relationship has values ( %s, %s, %v)", funcName, k, reflect.TypeOf(v), reflect.ValueOf(v).Interface())
}
gotJSON, err := json.Marshal(er)
if err != nil {
t.Error("%s Could not construct JSON %v", funcName, err)
count.FailCount++
return
}
log.Printf("%s Successfully created entity relationship %v", funcName, string(gotJSON))
count.SuccessCount++
}
示例15: TestMicroPageSvcDeletePage
func TestMicroPageSvcDeletePage(t *testing.T) {
log.SetPrefix(util.GetCallerName() + ":")
mps.Register(util.GetConfig().RootPath, util.GetConfig().ApiVersion, "/page")
//mps.MicroSvc.AddModel(mockmodel.MockPageModel{})
tests := []resttest.RESTTestContainer{
{
Desc: "DeletePage",
Handler: restful.DefaultContainer.ServeHTTP,
Path: "%1/%2",
Sub: map[string]string{
"%1": mps.MicroSvc.GetFullPath(),
"%2": "3",
},
Method: "DELETE",
Status: http.StatusOK,
PreAuthId: 7,
OwnThreshold: 0,
GlobalThreshold: 0,
},
}
//mod, _ := mps.MicroSvc.getModel(mps.MicroSvc.GetFullPath())
//log.Println("----------------------------------------------------------------------------")
//log.Printf("----- Testing with Model ( %s )---------------------", reflect.TypeOf(mod))
//log.Println("----------------------------------------------------------------------------")
//resttest.RunTestSet(t, tests)
// Test w/Actual database
mps.MicroSvc.AddModel(model.PageModel{})
mod, _ := mps.MicroSvc.getModel(mps.MicroSvc.GetFullPath())
log.Println("----------------------------------------------------------------------------")
log.Printf("----- Testing with Model ( %s )---------------------", reflect.TypeOf(mod))
log.Println("----------------------------------------------------------------------------")
resttest.RunTestSet(t, tests)
log.SetPrefix("")
}