httplib: fix unstable test, do not use httplib.org

This commit is contained in:
Deng Ming
2023-06-04 14:26:53 +08:00
parent 4f4cf565f0
commit 3e96b23551
86 changed files with 1166 additions and 917 deletions

View File

@@ -106,8 +106,10 @@ func MockDeleteWithCtx(tableName string, affectedRow int64, err error) *Mock {
// Now you may be need to use golang/mock to generate QueryM2M mock instance
// Or use DoNothingQueryM2Mer
// for example:
// post := Post{Id: 4}
// m2m := Ormer.QueryM2M(&post, "Tags")
//
// post := Post{Id: 4}
// m2m := Ormer.QueryM2M(&post, "Tags")
//
// when you write test code:
// MockQueryM2MWithCtx("post", "Tags", mockM2Mer)
// "post" is the table name of model Post structure

View File

@@ -50,7 +50,6 @@
// // delete
// num, err = o.Delete(&u)
// }
//
package orm
import (
@@ -324,8 +323,9 @@ func (o *ormBase) QueryM2MWithCtx(_ context.Context, md interface{}, name string
// args are limit, offset int and order string.
//
// example:
// orm.LoadRelated(post,"Tags")
// for _,tag := range post.Tags{...}
//
// orm.LoadRelated(post,"Tags")
// for _,tag := range post.Tags{...}
//
// make sure the relation is defined in model struct tags.
func (o *ormBase) LoadRelated(md interface{}, name string, args ...utils.KV) (int64, error) {

View File

@@ -30,9 +30,10 @@ type queryM2M struct {
// add models to origin models when creating queryM2M.
// example:
// m2m := orm.QueryM2M(post,"Tag")
// m2m.Add(&Tag1{},&Tag2{})
// for _,tag := range post.Tags{}
//
// m2m := orm.QueryM2M(post,"Tag")
// m2m.Add(&Tag1{},&Tag2{})
// for _,tag := range post.Tags{}
//
// make sure the relation is defined in post model struct tag.
func (o *queryM2M) Add(mds ...interface{}) (int64, error) {

View File

@@ -43,9 +43,10 @@ const (
)
// ColValue do the field raw changes. e.g Nums = Nums + 10. usage:
// Params{
// "Nums": ColValue(Col_Add, 10),
// }
//
// Params{
// "Nums": ColValue(Col_Add, 10),
// }
func ColValue(opt operator, value interface{}) interface{} {
switch opt {
case ColAdd, ColMinus, ColMultiply, ColExcept, ColBitAnd, ColBitRShift,
@@ -260,8 +261,9 @@ func (o *querySet) DeleteWithCtx(ctx context.Context) (int64, error) {
// return an insert queryer.
// it can be used in times.
// example:
// i,err := sq.PrepareInsert()
// i.Add(&user1{},&user2{})
//
// i,err := sq.PrepareInsert()
// i.Add(&user1{},&user2{})
func (o *querySet) PrepareInsert() (Inserter, error) {
return o.PrepareInsertWithCtx(context.Background())
}
@@ -339,10 +341,11 @@ func (o *querySet) ValuesFlatWithCtx(ctx context.Context, result *ParamsList, ex
// name | value
// total | 100
// found | 200
// to map[string]interface{}{
// "total": 100,
// "found": 200,
// }
//
// to map[string]interface{}{
// "total": 100,
// "found": 200,
// }
func (o *querySet) RowsToMap(result *Params, keyCol, valueCol string) (int64, error) {
panic(ErrNotImplement)
}
@@ -353,10 +356,11 @@ func (o *querySet) RowsToMap(result *Params, keyCol, valueCol string) (int64, er
// name | value
// total | 100
// found | 200
// to struct {
// Total int
// Found int
// }
//
// to struct {
// Total int
// Found int
// }
func (o *querySet) RowsToStruct(ptrStruct interface{}, keyCol, valueCol string) (int64, error) {
panic(ErrNotImplement)
}

View File

@@ -874,10 +874,11 @@ func (o *rawSet) ValuesFlat(container *ParamsList, cols ...string) (int64, error
// name | value
// total | 100
// found | 200
// to map[string]interface{}{
// "total": 100,
// "found": 200,
// }
//
// to map[string]interface{}{
// "total": 100,
// "found": 200,
// }
func (o *rawSet) RowsToMap(result *Params, keyCol, valueCol string) (int64, error) {
return o.queryRowsTo(result, keyCol, valueCol)
}
@@ -888,10 +889,11 @@ func (o *rawSet) RowsToMap(result *Params, keyCol, valueCol string) (int64, erro
// name | value
// total | 100
// found | 200
// to struct {
// Total int
// Found int
// }
//
// to struct {
// Total int
// Found int
// }
func (o *rawSet) RowsToStruct(ptrStruct interface{}, keyCol, valueCol string) (int64, error) {
return o.queryRowsTo(ptrStruct, keyCol, valueCol)
}

View File

@@ -27,12 +27,14 @@ import (
// TableNaming is usually used by model
// when you custom your table name, please implement this interfaces
// for example:
// type User struct {
// ...
// }
// func (u *User) TableName() string {
// return "USER_TABLE"
// }
//
// type User struct {
// ...
// }
//
// func (u *User) TableName() string {
// return "USER_TABLE"
// }
type TableNameI interface {
TableName() string
}
@@ -40,12 +42,14 @@ type TableNameI interface {
// TableEngineI is usually used by model
// when you want to use specific engine, like myisam, you can implement this interface
// for example:
// type User struct {
// ...
// }
// func (u *User) TableEngine() string {
// return "myisam"
// }
//
// type User struct {
// ...
// }
//
// func (u *User) TableEngine() string {
// return "myisam"
// }
type TableEngineI interface {
TableEngine() string
}
@@ -53,12 +57,14 @@ type TableEngineI interface {
// TableIndexI is usually used by model
// when you want to create indexes, you can implement this interface
// for example:
// type User struct {
// ...
// }
// func (u *User) TableIndex() [][]string {
// return [][]string{{"Name"}}
// }
//
// type User struct {
// ...
// }
//
// func (u *User) TableIndex() [][]string {
// return [][]string{{"Name"}}
// }
type TableIndexI interface {
TableIndex() [][]string
}
@@ -66,12 +72,14 @@ type TableIndexI interface {
// TableUniqueI is usually used by model
// when you want to create unique indexes, you can implement this interface
// for example:
// type User struct {
// ...
// }
// func (u *User) TableUnique() [][]string {
// return [][]string{{"Email"}}
// }
//
// type User struct {
// ...
// }
//
// func (u *User) TableUnique() [][]string {
// return [][]string{{"Email"}}
// }
type TableUniqueI interface {
TableUnique() [][]string
}
@@ -526,8 +534,9 @@ type RawPreparer interface {
// RawSeter raw query seter
// create From Ormer.Raw
// for example:
// sql := fmt.Sprintf("SELECT %sid%s,%sname%s FROM %suser%s WHERE id = ?",Q,Q,Q,Q,Q,Q)
// rs := Ormer.Raw(sql, 1)
//
// sql := fmt.Sprintf("SELECT %sid%s,%sname%s FROM %suser%s WHERE id = ?",Q,Q,Q,Q,Q,Q)
// rs := Ormer.Raw(sql, 1)
type RawSeter interface {
// execute sql and get result
Exec() (sql.Result, error)