Skip to content

Commit

Permalink
add test for defensive section
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Braithwaite committed Mar 31, 2021
1 parent be2db39 commit df9bf98
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions named_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sqlx
import (
"database/sql"
"fmt"
"regexp"
"testing"
)

Expand Down Expand Up @@ -352,4 +353,17 @@ func TestFixBounds(t *testing.T) {
})
}

t.Run("regex changed", func(t *testing.T) {
var valueBracketRegChanged = regexp.MustCompile(`(VALUES)\s+(\([^(]*.[^(]\))`)
saveRegexp := valueBracketReg
defer func() {
valueBracketReg = saveRegexp
}()
valueBracketReg = valueBracketRegChanged

res := fixBound("VALUES (:a, :b)", 2)
if res != "VALUES (:a, :b)" {
t.Errorf("changed regex should return string")
}
})
}

0 comments on commit df9bf98

Please sign in to comment.