Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move old bson package #4177

Merged
merged 5 commits into from Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .golangci.yml
Expand Up @@ -26,12 +26,12 @@ linters-settings:
desc: use `github.com/jackc/pgx/v5` package instead
- pkg: github.com/jackc/pgx/v4
desc: use `github.com/jackc/pgx/v5` package instead
bson:
oldbson:
files:
- $all
- "!**/internal/bson2/*_test.go"
- "!**/internal/bson2/bson2_test.go"
deny:
- pkg: github.com/FerretDB/FerretDB/internal/bson$
- pkg: github.com/FerretDB/FerretDB/internal/bson/oldbson$
bson2:
files:
- $all
Expand Down
22 changes: 11 additions & 11 deletions internal/bson2/bson2_test.go
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/FerretDB/FerretDB/internal/bson"
"github.com/FerretDB/FerretDB/internal/bson2"
"github.com/FerretDB/FerretDB/internal/bson2/oldbson"
"github.com/FerretDB/FerretDB/internal/types"
"github.com/FerretDB/FerretDB/internal/util/must"
"github.com/FerretDB/FerretDB/internal/util/testutil"
Expand Down Expand Up @@ -587,9 +587,9 @@ var decodeTestCases = []decodeTestCase{
func TestNormal(t *testing.T) {
for _, tc := range normalTestCases {
t.Run(tc.name, func(t *testing.T) {
t.Run("bson", func(t *testing.T) {
t.Run("oldbson", func(t *testing.T) {
t.Run("ReadFrom", func(t *testing.T) {
var doc bson.Document
var doc oldbson.Document
buf := bufio.NewReader(bytes.NewReader(tc.raw))
err := doc.ReadFrom(buf)
require.NoError(t, err)
Expand All @@ -603,7 +603,7 @@ func TestNormal(t *testing.T) {
})

t.Run("MarshalBinary", func(t *testing.T) {
doc, err := bson.ConvertDocument(tc.tdoc)
doc, err := oldbson.ConvertDocument(tc.tdoc)
require.NoError(t, err)

raw, err := doc.MarshalBinary()
Expand Down Expand Up @@ -688,9 +688,9 @@ func TestDecode(t *testing.T) {
require.NotNil(t, tc.decodeDeepErr, "invalid test case %q", tc.name)

t.Run(tc.name, func(t *testing.T) {
t.Run("bson", func(t *testing.T) {
t.Run("oldbson", func(t *testing.T) {
t.Run("ReadFrom", func(t *testing.T) {
var doc bson.Document
var doc oldbson.Document
buf := bufio.NewReader(bytes.NewReader(tc.raw))
err := doc.ReadFrom(buf)

Expand Down Expand Up @@ -746,9 +746,9 @@ func TestDecode(t *testing.T) {
func BenchmarkDocument(b *testing.B) {
for _, tc := range normalTestCases {
b.Run(tc.name, func(b *testing.B) {
b.Run("bson", func(b *testing.B) {
b.Run("oldbson", func(b *testing.B) {
b.Run("ReadFrom", func(b *testing.B) {
var doc bson.Document
var doc oldbson.Document
var buf *bufio.Reader
var err error
br := bytes.NewReader(tc.raw)
Expand All @@ -768,7 +768,7 @@ func BenchmarkDocument(b *testing.B) {
})

b.Run("MarshalBinary", func(b *testing.B) {
doc, err := bson.ConvertDocument(tc.tdoc)
doc, err := oldbson.ConvertDocument(tc.tdoc)
require.NoError(b, err)

var raw []byte
Expand Down Expand Up @@ -956,7 +956,7 @@ func testRawDocument(t *testing.T, rawDoc bson2.RawDocument) {
br := bytes.NewReader(rawDoc)
bufr := bufio.NewReader(br)

var doc1 bson.Document
var doc1 oldbson.Document
err1 := doc1.ReadFrom(bufr)

if err1 != nil {
Expand Down Expand Up @@ -994,7 +994,7 @@ func testRawDocument(t *testing.T, rawDoc bson2.RawDocument) {

// encode

doc1e, err := bson.ConvertDocument(tdoc1)
doc1e, err := oldbson.ConvertDocument(tdoc1)
require.NoError(t, err)

doc2e, err := bson2.ConvertDocument(tdoc2)
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"testing"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion internal/bson/bool.go → internal/bson2/oldbson/bool.go
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"testing"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"testing"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"testing"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"testing"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"math"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"math"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"math"
Expand Down
2 changes: 1 addition & 1 deletion internal/bson/null.go → internal/bson2/oldbson/null.go
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"testing"
Expand Down
33 changes: 2 additions & 31 deletions internal/bson/bson.go → internal/bson2/oldbson/oldbson.go
Expand Up @@ -12,37 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package bson provides converters from/to BSON for built-in and `types` types.
//
// See contributing guidelines and documentation for package `types` for details.
//
// # Mapping
//
// Composite types
//
// Alias types package bson package
//
// object *types.Document *bson.Document
// array *types.Array *bson.arrayType
//
// Scalar types
//
// Alias types package bson package
//
// double float64 *bson.doubleType
// string string *bson.stringType
// binData types.Binary *bson.binaryType
// objectId types.ObjectID *bson.objectIDType
// bool bool *bson.boolType
// date time.Time *bson.dateTimeType
// null types.NullType *bson.nullType
// regex types.Regex *bson.regexType
// int int32 *bson.int32Type
// timestamp types.Timestamp *bson.timestampType
// long int64 *bson.int64Type
//
//nolint:dupword // false positive
package bson
// Package oldbson contains old implementation of BSON that is used for cross-testing only.
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"testing"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"bufio"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

import (
"testing"
Expand Down
4 changes: 2 additions & 2 deletions internal/bson/tag.go → internal/bson2/oldbson/tag.go
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package bson
package oldbson

//go:generate ../../bin/stringer -linecomment -type tag
//go:generate ../../../bin/stringer -linecomment -type tag

type tag byte

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.