diff --git a/session_sum_test.go b/session_sum_test.go index 5cfd7283..59e0f3cd 100644 --- a/session_sum_test.go +++ b/session_sum_test.go @@ -17,6 +17,8 @@ func isFloatEq(i, j float64, precision int) bool { } func TestSum(t *testing.T) { + assert.NoError(t, prepareEngine()) + type SumStruct struct { Int int Float float32 diff --git a/session_update_test.go b/session_update_test.go new file mode 100644 index 00000000..eb1b79df --- /dev/null +++ b/session_update_test.go @@ -0,0 +1,36 @@ +// Copyright 2017 The Xorm Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package xorm + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestUpdateMap(t *testing.T) { + assert.NoError(t, prepareEngine()) + + type UpdateTable struct { + Id int64 + Name string + Age int + } + + assert.NoError(t, testEngine.Sync2(new(UpdateTable))) + var tb = UpdateTable{ + Name: "test", + Age: 35, + } + _, err := testEngine.Insert(&tb) + assert.NoError(t, err) + + cnt, err := testEngine.Table("update_table").Where("id = ?", tb.Id).Update(map[string]interface{}{ + "name": "test2", + "age": 36, + }) + assert.NoError(t, err) + assert.EqualValues(t, 1, cnt) +}