forked from forgejo/forgejo
go1.16 (#14783)
This commit is contained in:
parent
030646eea4
commit
47f6a4ec3f
947 changed files with 26119 additions and 7062 deletions
8
vendor/github.com/go-testfixtures/testfixtures/v3/CHANGELOG.md
generated
vendored
8
vendor/github.com/go-testfixtures/testfixtures/v3/CHANGELOG.md
generated
vendored
|
@ -1,5 +1,13 @@
|
|||
# Changelog
|
||||
|
||||
## v3.5.0 - 2021-01-11
|
||||
|
||||
- Fix insert of JSON values on PostgreSQL when using `binary_parameters=yes` in
|
||||
the connection string
|
||||
([#83](https://github.com/go-testfixtures/testfixtures/issues/83), [#84](https://github.com/go-testfixtures/testfixtures/pull/84), [lib/pq#528](https://github.com/lib/pq/issues/528)).
|
||||
- Officially support binary columns through hexadecimal strings
|
||||
([#48](https://github.com/go-testfixtures/testfixtures/issues/48), [#82](https://github.com/go-testfixtures/testfixtures/pull/82)).
|
||||
|
||||
## v3.4.1 - 2020-10-19
|
||||
|
||||
- Fix for Microsoft SQL Server databases with views
|
||||
|
|
10
vendor/github.com/go-testfixtures/testfixtures/v3/README.md
generated
vendored
10
vendor/github.com/go-testfixtures/testfixtures/v3/README.md
generated
vendored
|
@ -90,6 +90,13 @@ databases.
|
|||
post: "..."
|
||||
```
|
||||
|
||||
Binary columns can be represented as hexadecimal strings (should start with `0x`):
|
||||
|
||||
```yaml
|
||||
- id: 1
|
||||
binary_column: 0x1234567890abcdef
|
||||
```
|
||||
|
||||
If you need to write raw SQL, probably to call a function, prefix the value
|
||||
of the column with `RAW=`:
|
||||
|
||||
|
@ -129,7 +136,7 @@ func TestMain(m *testing.M) {
|
|||
...
|
||||
}
|
||||
|
||||
fixtures, err := testfixtures.New(
|
||||
fixtures, err = testfixtures.New(
|
||||
testfixtures.Database(db), // You database connection
|
||||
testfixtures.Dialect("postgres"), // Available: "postgresql", "timescaledb", "mysql", "mariadb", "sqlite" and "sqlserver"
|
||||
testfixtures.Directory("testdata/fixtures"), // the directory containing the YAML files
|
||||
|
@ -497,6 +504,7 @@ unit test database code without having to connect to a real database
|
|||
- [dbcleaner][dbcleaner] - Clean database for testing, inspired by
|
||||
database_cleaner for Ruby
|
||||
|
||||
[doc]: https://pkg.go.dev/github.com/go-testfixtures/testfixtures/v3?tab=doc
|
||||
[railstests]: http://guides.rubyonrails.org/testing.html#the-test-database
|
||||
[gotxdb]: https://github.com/DATA-DOG/go-txdb
|
||||
[gosqlmock]: https://github.com/DATA-DOG/go-sqlmock
|
||||
|
|
14
vendor/github.com/go-testfixtures/testfixtures/v3/bytes.go
generated
vendored
Normal file
14
vendor/github.com/go-testfixtures/testfixtures/v3/bytes.go
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
package testfixtures
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (l *Loader) tryHexStringToBytes(s string) ([]byte, error) {
|
||||
if !strings.HasPrefix(s, "0x") {
|
||||
return nil, fmt.Errorf("not a hexadecimal string, must be prefix 0x")
|
||||
}
|
||||
return hex.DecodeString(strings.TrimPrefix(s, "0x"))
|
||||
}
|
2
vendor/github.com/go-testfixtures/testfixtures/v3/dump.go
generated
vendored
2
vendor/github.com/go-testfixtures/testfixtures/v3/dump.go
generated
vendored
|
@ -2,6 +2,7 @@ package testfixtures
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -160,6 +161,7 @@ func convertValue(value interface{}) interface{} {
|
|||
if utf8.Valid(v) {
|
||||
return string(v)
|
||||
}
|
||||
return "0x" + hex.EncodeToString(value.([]byte))
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
|
13
vendor/github.com/go-testfixtures/testfixtures/v3/testfixtures.go
generated
vendored
13
vendor/github.com/go-testfixtures/testfixtures/v3/testfixtures.go
generated
vendored
|
@ -3,6 +3,7 @@ package testfixtures // import "github.com/go-testfixtures/testfixtures/v3"
|
|||
import (
|
||||
"bytes"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -496,12 +497,18 @@ func (l *Loader) buildInsertSQL(f *fixtureFile, record map[interface{}]interface
|
|||
sqlValues = append(sqlValues, strings.TrimPrefix(v, "RAW="))
|
||||
continue
|
||||
}
|
||||
|
||||
if t, err := l.tryStrToDate(v); err == nil {
|
||||
if b, err := l.tryHexStringToBytes(v); err == nil {
|
||||
value = b
|
||||
} else if t, err := l.tryStrToDate(v); err == nil {
|
||||
value = t
|
||||
}
|
||||
case []interface{}, map[interface{}]interface{}:
|
||||
value = recursiveToJSON(v)
|
||||
var bytes []byte
|
||||
bytes, err = json.Marshal(recursiveToJSON(v))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
value = string(bytes)
|
||||
}
|
||||
|
||||
switch l.helper.paramType() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue