generated from clevergo/pkg-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
execer_test.go
42 lines (37 loc) · 941 Bytes
/
execer_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2020 CleverGo. All rights reserved.
// Use of this source code is governed by a MIT style license that can be found
// in the LICENSE file.
package sqlex
import (
"context"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestExec(t *testing.T) {
cases := []struct {
ctx context.Context
id string
}{
{nil, "exec"},
{context.Background(), "exec_context"},
}
for _, test := range cases {
_, err := Exec(test.ctx, mockDBx, fmt.Sprintf("INSERT INTO %s(id) VALUES (?)", mockTable), test.id)
assert.Nil(t, err)
assert.True(t, isMockRowExists(test.id))
}
}
func TestMustExec(t *testing.T) {
cases := []struct {
ctx context.Context
id string
}{
{nil, "mustexec"},
{context.Background(), "mustexec_context"},
}
for _, test := range cases {
MustExec(test.ctx, mockDBx, fmt.Sprintf("INSERT INTO %s(id) VALUES (?)", mockTable), test.id)
assert.True(t, isMockRowExists(test.id))
}
}