mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 00:20:55 +00:00
fix ineffectual
This commit is contained in:
parent
3e29078f68
commit
aa8f7bc146
@ -325,7 +325,10 @@ func (c *IniConfigContainer) SaveConfigFile(filename string) (err error) {
|
|||||||
|
|
||||||
// Get section or key comments. Fixed #1607
|
// Get section or key comments. Fixed #1607
|
||||||
getCommentStr := func(section, key string) string {
|
getCommentStr := func(section, key string) string {
|
||||||
comment, ok := "", false
|
var (
|
||||||
|
comment string
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
if len(key) == 0 {
|
if len(key) == 0 {
|
||||||
comment, ok = c.sectionComment[section]
|
comment, ok = c.sectionComment[section]
|
||||||
} else {
|
} else {
|
||||||
|
@ -361,7 +361,7 @@ func isParameterChar(b byte) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cw *ansiColorWriter) Write(p []byte) (int, error) {
|
func (cw *ansiColorWriter) Write(p []byte) (int, error) {
|
||||||
r, nw, first, last := 0, 0, 0, 0
|
var r, nw, first, last int
|
||||||
if cw.mode != DiscardNonColorEscSeq {
|
if cw.mode != DiscardNonColorEscSeq {
|
||||||
cw.state = outsideCsiCode
|
cw.state = outsideCsiCode
|
||||||
cw.resetBuffer()
|
cw.resetBuffer()
|
||||||
|
10
logs/file.go
10
logs/file.go
@ -259,7 +259,7 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error {
|
|||||||
}
|
}
|
||||||
// return error if the last file checked still existed
|
// return error if the last file checked still existed
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fmt.Errorf("Rotate: Cannot find free log number to rename %s\n", w.Filename)
|
return fmt.Errorf("Rotate: Cannot find free log number to rename %s", w.Filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
// close fileWriter before rename
|
// close fileWriter before rename
|
||||||
@ -268,6 +268,9 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error {
|
|||||||
// Rename the file to its new found name
|
// Rename the file to its new found name
|
||||||
// even if occurs error,we MUST guarantee to restart new logger
|
// even if occurs error,we MUST guarantee to restart new logger
|
||||||
err = os.Rename(w.Filename, fName)
|
err = os.Rename(w.Filename, fName)
|
||||||
|
if err != nil {
|
||||||
|
goto RESTART_LOGGER
|
||||||
|
}
|
||||||
err = os.Chmod(fName, os.FileMode(0440))
|
err = os.Chmod(fName, os.FileMode(0440))
|
||||||
// re-start logger
|
// re-start logger
|
||||||
RESTART_LOGGER:
|
RESTART_LOGGER:
|
||||||
@ -276,13 +279,12 @@ RESTART_LOGGER:
|
|||||||
go w.deleteOldLog()
|
go w.deleteOldLog()
|
||||||
|
|
||||||
if startLoggerErr != nil {
|
if startLoggerErr != nil {
|
||||||
return fmt.Errorf("Rotate StartLogger: %s\n", startLoggerErr)
|
return fmt.Errorf("Rotate StartLogger: %s", startLoggerErr)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Rotate: %s\n", err)
|
return fmt.Errorf("Rotate: %s", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *fileLogWriter) deleteOldLog() {
|
func (w *fileLogWriter) deleteOldLog() {
|
||||||
|
@ -1110,7 +1110,7 @@ func (d *dbBase) Count(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condition
|
|||||||
|
|
||||||
// generate sql with replacing operator string placeholders and replaced values.
|
// generate sql with replacing operator string placeholders and replaced values.
|
||||||
func (d *dbBase) GenerateOperatorSQL(mi *modelInfo, fi *fieldInfo, operator string, args []interface{}, tz *time.Location) (string, []interface{}) {
|
func (d *dbBase) GenerateOperatorSQL(mi *modelInfo, fi *fieldInfo, operator string, args []interface{}, tz *time.Location) (string, []interface{}) {
|
||||||
sql := ""
|
var sql string
|
||||||
params := getFlatParams(fi, args, tz)
|
params := getFlatParams(fi, args, tz)
|
||||||
|
|
||||||
if len(params) == 0 {
|
if len(params) == 0 {
|
||||||
|
@ -103,8 +103,7 @@ func (d *dbBaseMysql) IndexExists(db dbQuerier, table string, name string) bool
|
|||||||
// If no will insert
|
// If no will insert
|
||||||
// Add "`" for mysql sql building
|
// Add "`" for mysql sql building
|
||||||
func (d *dbBaseMysql) InsertOrUpdate(q dbQuerier, mi *modelInfo, ind reflect.Value, a *alias, args ...string) (int64, error) {
|
func (d *dbBaseMysql) InsertOrUpdate(q dbQuerier, mi *modelInfo, ind reflect.Value, a *alias, args ...string) (int64, error) {
|
||||||
|
var iouStr string
|
||||||
iouStr := ""
|
|
||||||
argsMap := map[string]string{}
|
argsMap := map[string]string{}
|
||||||
|
|
||||||
iouStr = "ON DUPLICATE KEY UPDATE"
|
iouStr = "ON DUPLICATE KEY UPDATE"
|
||||||
|
@ -420,7 +420,7 @@ func (o *orm) getRelQs(md interface{}, mi *modelInfo, fi *fieldInfo) *querySet {
|
|||||||
// table name can be string or struct.
|
// table name can be string or struct.
|
||||||
// e.g. QueryTable("user"), QueryTable(&user{}) or QueryTable((*User)(nil)),
|
// e.g. QueryTable("user"), QueryTable(&user{}) or QueryTable((*User)(nil)),
|
||||||
func (o *orm) QueryTable(ptrStructOrTableName interface{}) (qs QuerySeter) {
|
func (o *orm) QueryTable(ptrStructOrTableName interface{}) (qs QuerySeter) {
|
||||||
name := ""
|
var name string
|
||||||
if table, ok := ptrStructOrTableName.(string); ok {
|
if table, ok := ptrStructOrTableName.(string); ok {
|
||||||
name = snakeString(table)
|
name = snakeString(table)
|
||||||
if mi, ok := modelCache.get(name); ok {
|
if mi, ok := modelCache.get(name); ok {
|
||||||
|
@ -671,7 +671,7 @@ func (o *rawSet) queryRowsTo(container interface{}, keyCol, valueCol string) (in
|
|||||||
ind *reflect.Value
|
ind *reflect.Value
|
||||||
)
|
)
|
||||||
|
|
||||||
typ := 0
|
var typ int
|
||||||
switch container.(type) {
|
switch container.(type) {
|
||||||
case *Params:
|
case *Params:
|
||||||
typ = 1
|
typ = 1
|
||||||
|
@ -1140,6 +1140,7 @@ func TestRelatedSel(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = qs.Filter("user_name", "nobody").RelatedSel("profile").One(&user)
|
err = qs.Filter("user_name", "nobody").RelatedSel("profile").One(&user)
|
||||||
|
throwFail(t, err)
|
||||||
throwFail(t, AssertIs(num, 1))
|
throwFail(t, AssertIs(num, 1))
|
||||||
throwFail(t, AssertIs(user.Profile, nil))
|
throwFail(t, AssertIs(user.Profile, nil))
|
||||||
|
|
||||||
@ -1248,20 +1249,24 @@ func TestLoadRelated(t *testing.T) {
|
|||||||
|
|
||||||
num, err = dORM.LoadRelated(&user, "Posts", true)
|
num, err = dORM.LoadRelated(&user, "Posts", true)
|
||||||
throwFailNow(t, err)
|
throwFailNow(t, err)
|
||||||
|
throwFailNow(t, AssertIs(num, 2))
|
||||||
throwFailNow(t, AssertIs(len(user.Posts), 2))
|
throwFailNow(t, AssertIs(len(user.Posts), 2))
|
||||||
throwFailNow(t, AssertIs(user.Posts[0].User.UserName, "astaxie"))
|
throwFailNow(t, AssertIs(user.Posts[0].User.UserName, "astaxie"))
|
||||||
|
|
||||||
num, err = dORM.LoadRelated(&user, "Posts", true, 1)
|
num, err = dORM.LoadRelated(&user, "Posts", true, 1)
|
||||||
throwFailNow(t, err)
|
throwFailNow(t, err)
|
||||||
|
throwFailNow(t, AssertIs(num, 1))
|
||||||
throwFailNow(t, AssertIs(len(user.Posts), 1))
|
throwFailNow(t, AssertIs(len(user.Posts), 1))
|
||||||
|
|
||||||
num, err = dORM.LoadRelated(&user, "Posts", true, 0, 0, "-Id")
|
num, err = dORM.LoadRelated(&user, "Posts", true, 0, 0, "-Id")
|
||||||
throwFailNow(t, err)
|
throwFailNow(t, err)
|
||||||
|
throwFailNow(t, AssertIs(num, 2))
|
||||||
throwFailNow(t, AssertIs(len(user.Posts), 2))
|
throwFailNow(t, AssertIs(len(user.Posts), 2))
|
||||||
throwFailNow(t, AssertIs(user.Posts[0].Title, "Formatting"))
|
throwFailNow(t, AssertIs(user.Posts[0].Title, "Formatting"))
|
||||||
|
|
||||||
num, err = dORM.LoadRelated(&user, "Posts", true, 1, 1, "Id")
|
num, err = dORM.LoadRelated(&user, "Posts", true, 1, 1, "Id")
|
||||||
throwFailNow(t, err)
|
throwFailNow(t, err)
|
||||||
|
throwFailNow(t, AssertIs(num, 1))
|
||||||
throwFailNow(t, AssertIs(len(user.Posts), 1))
|
throwFailNow(t, AssertIs(len(user.Posts), 1))
|
||||||
throwFailNow(t, AssertIs(user.Posts[0].Title, "Formatting"))
|
throwFailNow(t, AssertIs(user.Posts[0].Title, "Formatting"))
|
||||||
|
|
||||||
@ -1978,6 +1983,7 @@ func TestReadOrCreate(t *testing.T) {
|
|||||||
created, pk, err := dORM.ReadOrCreate(u, "UserName")
|
created, pk, err := dORM.ReadOrCreate(u, "UserName")
|
||||||
throwFail(t, err)
|
throwFail(t, err)
|
||||||
throwFail(t, AssertIs(created, true))
|
throwFail(t, AssertIs(created, true))
|
||||||
|
throwFail(t, AssertIs(u.ID, pk))
|
||||||
throwFail(t, AssertIs(u.UserName, "Kyle"))
|
throwFail(t, AssertIs(u.UserName, "Kyle"))
|
||||||
throwFail(t, AssertIs(u.Email, "kylemcc@gmail.com"))
|
throwFail(t, AssertIs(u.Email, "kylemcc@gmail.com"))
|
||||||
throwFail(t, AssertIs(u.Password, "other_pass"))
|
throwFail(t, AssertIs(u.Password, "other_pass"))
|
||||||
@ -2134,6 +2140,7 @@ func TestUintPk(t *testing.T) {
|
|||||||
|
|
||||||
created, pk, err := dORM.ReadOrCreate(u, "ID")
|
created, pk, err := dORM.ReadOrCreate(u, "ID")
|
||||||
throwFail(t, err)
|
throwFail(t, err)
|
||||||
|
throwFail(t, AssertIs(pk, u.ID))
|
||||||
throwFail(t, AssertIs(created, true))
|
throwFail(t, AssertIs(created, true))
|
||||||
throwFail(t, AssertIs(u.Name, name))
|
throwFail(t, AssertIs(u.Name, name))
|
||||||
|
|
||||||
|
@ -162,7 +162,9 @@ func (cp *Provider) SessionRead(sid string) (session.Store, error) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
err = cp.b.Get(sid, &doc)
|
err = cp.b.Get(sid, &doc)
|
||||||
if doc == nil {
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if doc == nil {
|
||||||
kv = make(map[interface{}]interface{})
|
kv = make(map[interface{}]interface{})
|
||||||
} else {
|
} else {
|
||||||
kv, err = session.DecodeGob(doc)
|
kv, err = session.DecodeGob(doc)
|
||||||
|
@ -74,8 +74,7 @@ func TestCookieEncodeDecode(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("encodeCookie:", err)
|
t.Fatal("encodeCookie:", err)
|
||||||
}
|
}
|
||||||
dst := make(map[interface{}]interface{})
|
dst, err := decodeCookie(block, hashKey, securityName, str, 3600)
|
||||||
dst, err = decodeCookie(block, hashKey, securityName, str, 3600)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("decodeCookie", err)
|
t.Fatal("decodeCookie", err)
|
||||||
}
|
}
|
||||||
|
@ -307,8 +307,9 @@ func _getTemplate(t0 *template.Template, root string, subMods [][]string, others
|
|||||||
}
|
}
|
||||||
//second check define
|
//second check define
|
||||||
for _, otherFile := range others {
|
for _, otherFile := range others {
|
||||||
|
var data []byte
|
||||||
fileAbsPath := filepath.Join(root, otherFile)
|
fileAbsPath := filepath.Join(root, otherFile)
|
||||||
data, err := ioutil.ReadFile(fileAbsPath)
|
data, err = ioutil.ReadFile(fileAbsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -254,22 +254,22 @@ func TestParseFormTag(t *testing.T) {
|
|||||||
|
|
||||||
objT := reflect.TypeOf(&user{}).Elem()
|
objT := reflect.TypeOf(&user{}).Elem()
|
||||||
|
|
||||||
label, name, fType, id, class, ignored, required := parseFormTag(objT.Field(0))
|
label, name, fType, _, _, ignored, _ := parseFormTag(objT.Field(0))
|
||||||
if !(name == "name" && label == "年龄:" && fType == "text" && !ignored) {
|
if !(name == "name" && label == "年龄:" && fType == "text" && !ignored) {
|
||||||
t.Errorf("Form Tag with name, label and type was not correctly parsed.")
|
t.Errorf("Form Tag with name, label and type was not correctly parsed.")
|
||||||
}
|
}
|
||||||
|
|
||||||
label, name, fType, id, class, ignored, required = parseFormTag(objT.Field(1))
|
label, name, fType, _, _, ignored, _ = parseFormTag(objT.Field(1))
|
||||||
if !(name == "NoName" && label == "年龄:" && fType == "hidden" && !ignored) {
|
if !(name == "NoName" && label == "年龄:" && fType == "hidden" && !ignored) {
|
||||||
t.Errorf("Form Tag with label and type but without name was not correctly parsed.")
|
t.Errorf("Form Tag with label and type but without name was not correctly parsed.")
|
||||||
}
|
}
|
||||||
|
|
||||||
label, name, fType, id, class, ignored, required = parseFormTag(objT.Field(2))
|
label, name, fType, _, _, ignored, _ = parseFormTag(objT.Field(2))
|
||||||
if !(name == "OnlyLabel" && label == "年龄:" && fType == "text" && !ignored) {
|
if !(name == "OnlyLabel" && label == "年龄:" && fType == "text" && !ignored) {
|
||||||
t.Errorf("Form Tag containing only label was not correctly parsed.")
|
t.Errorf("Form Tag containing only label was not correctly parsed.")
|
||||||
}
|
}
|
||||||
|
|
||||||
label, name, fType, id, class, ignored, _ = parseFormTag(objT.Field(3))
|
label, name, fType, id, class, ignored, _ := parseFormTag(objT.Field(3))
|
||||||
if !(name == "name" && label == "OnlyName: " && fType == "text" && !ignored &&
|
if !(name == "name" && label == "OnlyName: " && fType == "text" && !ignored &&
|
||||||
id == "name" && class == "form-name") {
|
id == "name" && class == "form-name") {
|
||||||
t.Errorf("Form Tag containing only name was not correctly parsed.")
|
t.Errorf("Form Tag containing only name was not correctly parsed.")
|
||||||
@ -280,7 +280,7 @@ func TestParseFormTag(t *testing.T) {
|
|||||||
t.Errorf("Form Tag that should be ignored was not correctly parsed.")
|
t.Errorf("Form Tag that should be ignored was not correctly parsed.")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, name, _, _, _, _, required = parseFormTag(objT.Field(5))
|
_, name, _, _, _, _, required := parseFormTag(objT.Field(5))
|
||||||
if !(name == "name" && required) {
|
if !(name == "name" && required) {
|
||||||
t.Errorf("Form Tag containing only name and required was not correctly parsed.")
|
t.Errorf("Form Tag containing only name and required was not correctly parsed.")
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ func GrepFile(patten string, filename string) (lines []string, err error) {
|
|||||||
lines = make([]string, 0)
|
lines = make([]string, 0)
|
||||||
reader := bufio.NewReader(fd)
|
reader := bufio.NewReader(fd)
|
||||||
prefix := ""
|
prefix := ""
|
||||||
isLongLine := false
|
var isLongLine bool
|
||||||
for {
|
for {
|
||||||
byteLine, isPrefix, er := reader.ReadLine()
|
byteLine, isPrefix, er := reader.ReadLine()
|
||||||
if er != nil && er != io.EOF {
|
if er != nil && er != io.EOF {
|
||||||
|
@ -42,7 +42,7 @@ func TestGetValidFuncs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
f, _ = tf.FieldByName("Tag")
|
f, _ = tf.FieldByName("Tag")
|
||||||
if vfs, err = getValidFuncs(f); err.Error() != "doesn't exsits Maxx valid function" {
|
if _, err = getValidFuncs(f); err.Error() != "doesn't exsits Maxx valid function" {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user