Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
Signed-off-by: joccau <[email protected]>
  • Loading branch information
joccau committed Sep 16, 2022
1 parent ee00689 commit c11d0f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 5 additions & 4 deletions br/pkg/utils/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import (

var (
// check sql.DB and sql.Conn implement QueryExecutor and DBExecutor
_ DBExecutor = &sql.DB{}
_ DBExecutor = &sql.Conn{}
_ DBExecutor = &sql.DB{}
_ DBExecutor = &sql.Conn{}
logBackupTaskExist bool
)

// QueryExecutor is a interface for exec query
Expand Down Expand Up @@ -90,12 +91,12 @@ func IsLogBackupEnabled(ctx sqlexec.RestrictedSQLExecutor) (bool, error) {
return true, nil
}

var logBackupTaskExist bool

// SetLogBackupTaskExist sets that the log-backup task is existed.
func SetLogBackupTaskExist(taskExist bool) {
logBackupTaskExist = taskExist
}

// CheckLogBackupTaskExist checks that whether log-backup is existed.
func CheckLogBackupTaskExist() bool {
return logBackupTaskExist
}
8 changes: 8 additions & 0 deletions br/pkg/utils/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,11 @@ func TestIsLogBackupEnabled(t *testing.T) {
require.Error(t, err)
require.False(t, enabled)
}

func TestCheckLogBackupTaskExist(t *testing.T) {
require.False(t, utils.CheckLogBackupTaskExist())
utils.SetLogBackupTaskExist(true)
require.True(t, utils.CheckLogBackupTaskExist())
utils.SetLogBackupTaskExist(false)
require.False(t, utils.CheckLogBackupTaskExist())
}

0 comments on commit c11d0f3

Please sign in to comment.