diff --git a/.golangci.yml b/.golangci.yml index 4db9da06965c..da160ae7b3ee 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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 diff --git a/internal/bson2/bson2_test.go b/internal/bson2/bson2_test.go index 70c94929cb67..ed73d6f7efa4 100644 --- a/internal/bson2/bson2_test.go +++ b/internal/bson2/bson2_test.go @@ -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" @@ -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) @@ -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() @@ -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) @@ -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) @@ -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 @@ -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 { @@ -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) diff --git a/internal/bson/array.go b/internal/bson2/oldbson/array.go similarity index 99% rename from internal/bson/array.go rename to internal/bson2/oldbson/array.go index b720b9e5e76a..5eb1c69c91f5 100644 --- a/internal/bson/array.go +++ b/internal/bson2/oldbson/array.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/array_test.go b/internal/bson2/oldbson/array_test.go similarity index 99% rename from internal/bson/array_test.go rename to internal/bson2/oldbson/array_test.go index 3ca9cd617e0f..7e177a19fc53 100644 --- a/internal/bson/array_test.go +++ b/internal/bson2/oldbson/array_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "testing" diff --git a/internal/bson/binary.go b/internal/bson2/oldbson/binary.go similarity index 99% rename from internal/bson/binary.go rename to internal/bson2/oldbson/binary.go index 38f65bdabcc1..e7d069a850aa 100644 --- a/internal/bson/binary.go +++ b/internal/bson2/oldbson/binary.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/binary_test.go b/internal/bson2/oldbson/binary_test.go similarity index 99% rename from internal/bson/binary_test.go rename to internal/bson2/oldbson/binary_test.go index 03741f3ee4e0..cc428bd4c493 100644 --- a/internal/bson/binary_test.go +++ b/internal/bson2/oldbson/binary_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "testing" diff --git a/internal/bson/bool.go b/internal/bson2/oldbson/bool.go similarity index 99% rename from internal/bson/bool.go rename to internal/bson2/oldbson/bool.go index 321dfe208741..649e3291a989 100644 --- a/internal/bson/bool.go +++ b/internal/bson2/oldbson/bool.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/bool_test.go b/internal/bson2/oldbson/bool_test.go similarity index 98% rename from internal/bson/bool_test.go rename to internal/bson2/oldbson/bool_test.go index 4685bd8bbb6c..b843dc265529 100644 --- a/internal/bson/bool_test.go +++ b/internal/bson2/oldbson/bool_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "testing" diff --git a/internal/bson/cstring.go b/internal/bson2/oldbson/cstring.go similarity index 99% rename from internal/bson/cstring.go rename to internal/bson2/oldbson/cstring.go index 7fa7548bcea4..d386272f4f85 100644 --- a/internal/bson/cstring.go +++ b/internal/bson2/oldbson/cstring.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/cstring_test.go b/internal/bson2/oldbson/cstring_test.go similarity index 98% rename from internal/bson/cstring_test.go rename to internal/bson2/oldbson/cstring_test.go index 681f61183bb2..6a9c876822c2 100644 --- a/internal/bson/cstring_test.go +++ b/internal/bson2/oldbson/cstring_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "testing" diff --git a/internal/bson/datetime.go b/internal/bson2/oldbson/datetime.go similarity index 99% rename from internal/bson/datetime.go rename to internal/bson2/oldbson/datetime.go index 8542b21fdf2c..9a25f5a03b25 100644 --- a/internal/bson/datetime.go +++ b/internal/bson2/oldbson/datetime.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/datetime_test.go b/internal/bson2/oldbson/datetime_test.go similarity index 99% rename from internal/bson/datetime_test.go rename to internal/bson2/oldbson/datetime_test.go index 7b11987ed061..578f49ae0344 100644 --- a/internal/bson/datetime_test.go +++ b/internal/bson2/oldbson/datetime_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "testing" diff --git a/internal/bson/document.go b/internal/bson2/oldbson/document.go similarity index 99% rename from internal/bson/document.go rename to internal/bson2/oldbson/document.go index 115a5881be89..3169e6e5f6fe 100644 --- a/internal/bson/document.go +++ b/internal/bson2/oldbson/document.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/document_test.go b/internal/bson2/oldbson/document_test.go similarity index 99% rename from internal/bson/document_test.go rename to internal/bson2/oldbson/document_test.go index dc357ca28f02..8352cf5ae768 100644 --- a/internal/bson/document_test.go +++ b/internal/bson2/oldbson/document_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "testing" diff --git a/internal/bson/double.go b/internal/bson2/oldbson/double.go similarity index 99% rename from internal/bson/double.go rename to internal/bson2/oldbson/double.go index 3661f2e7a5ae..5fe2eea86601 100644 --- a/internal/bson/double.go +++ b/internal/bson2/oldbson/double.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/double_test.go b/internal/bson2/oldbson/double_test.go similarity index 99% rename from internal/bson/double_test.go rename to internal/bson2/oldbson/double_test.go index 0bc6479235b0..77412aa72135 100644 --- a/internal/bson/double_test.go +++ b/internal/bson2/oldbson/double_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "math" diff --git a/internal/bson/int32.go b/internal/bson2/oldbson/int32.go similarity index 99% rename from internal/bson/int32.go rename to internal/bson2/oldbson/int32.go index 81751fb577a8..8358494db011 100644 --- a/internal/bson/int32.go +++ b/internal/bson2/oldbson/int32.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/int32_test.go b/internal/bson2/oldbson/int32_test.go similarity index 98% rename from internal/bson/int32_test.go rename to internal/bson2/oldbson/int32_test.go index db02ad320cb6..959fec248df1 100644 --- a/internal/bson/int32_test.go +++ b/internal/bson2/oldbson/int32_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "math" diff --git a/internal/bson/int64.go b/internal/bson2/oldbson/int64.go similarity index 99% rename from internal/bson/int64.go rename to internal/bson2/oldbson/int64.go index 9e0a00f2cfd3..751c995487dc 100644 --- a/internal/bson/int64.go +++ b/internal/bson2/oldbson/int64.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/int64_test.go b/internal/bson2/oldbson/int64_test.go similarity index 99% rename from internal/bson/int64_test.go rename to internal/bson2/oldbson/int64_test.go index 0f1ebcbacf8d..270561ea6d0b 100644 --- a/internal/bson/int64_test.go +++ b/internal/bson2/oldbson/int64_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "math" diff --git a/internal/bson/null.go b/internal/bson2/oldbson/null.go similarity index 98% rename from internal/bson/null.go rename to internal/bson2/oldbson/null.go index 4b0a3ca96933..3e4be1dee6a3 100644 --- a/internal/bson/null.go +++ b/internal/bson2/oldbson/null.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/object_id.go b/internal/bson2/oldbson/object_id.go similarity index 99% rename from internal/bson/object_id.go rename to internal/bson2/oldbson/object_id.go index 296b61c2e070..83ccb5daa4d0 100644 --- a/internal/bson/object_id.go +++ b/internal/bson2/oldbson/object_id.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/object_id_test.go b/internal/bson2/oldbson/object_id_test.go similarity index 98% rename from internal/bson/object_id_test.go rename to internal/bson2/oldbson/object_id_test.go index da0e6b893567..6ac38dd33c5e 100644 --- a/internal/bson/object_id_test.go +++ b/internal/bson2/oldbson/object_id_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "testing" diff --git a/internal/bson/bson.go b/internal/bson2/oldbson/oldbson.go similarity index 65% rename from internal/bson/bson.go rename to internal/bson2/oldbson/oldbson.go index e4ca224413b3..79a74423790e 100644 --- a/internal/bson/bson.go +++ b/internal/bson2/oldbson/oldbson.go @@ -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" diff --git a/internal/bson/bson_test.go b/internal/bson2/oldbson/oldbson_test.go similarity index 99% rename from internal/bson/bson_test.go rename to internal/bson2/oldbson/oldbson_test.go index 4a0897cd3e3c..6f6477ed1e63 100644 --- a/internal/bson/bson_test.go +++ b/internal/bson2/oldbson/oldbson_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/regex.go b/internal/bson2/oldbson/regex.go similarity index 99% rename from internal/bson/regex.go rename to internal/bson2/oldbson/regex.go index 81c0151afdce..36c02bef104f 100644 --- a/internal/bson/regex.go +++ b/internal/bson2/oldbson/regex.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/regex_test.go b/internal/bson2/oldbson/regex_test.go similarity index 98% rename from internal/bson/regex_test.go rename to internal/bson2/oldbson/regex_test.go index f031cd681ca4..b4490bb5c748 100644 --- a/internal/bson/regex_test.go +++ b/internal/bson2/oldbson/regex_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "testing" diff --git a/internal/bson/string.go b/internal/bson2/oldbson/string.go similarity index 99% rename from internal/bson/string.go rename to internal/bson2/oldbson/string.go index e5784714bf2b..f279ba679e1c 100644 --- a/internal/bson/string.go +++ b/internal/bson2/oldbson/string.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/string_test.go b/internal/bson2/oldbson/string_test.go similarity index 98% rename from internal/bson/string_test.go rename to internal/bson2/oldbson/string_test.go index a006ed8c3926..eb8a5a7ca7f4 100644 --- a/internal/bson/string_test.go +++ b/internal/bson2/oldbson/string_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "testing" diff --git a/internal/bson/tag.go b/internal/bson2/oldbson/tag.go similarity index 98% rename from internal/bson/tag.go rename to internal/bson2/oldbson/tag.go index c29fa7fe7f0a..c52ac1e7fae8 100644 --- a/internal/bson/tag.go +++ b/internal/bson2/oldbson/tag.go @@ -12,7 +12,7 @@ // 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 diff --git a/internal/bson/tag_string.go b/internal/bson2/oldbson/tag_string.go similarity index 98% rename from internal/bson/tag_string.go rename to internal/bson2/oldbson/tag_string.go index 6d154af244b7..56095d54e54e 100644 --- a/internal/bson/tag_string.go +++ b/internal/bson2/oldbson/tag_string.go @@ -1,6 +1,6 @@ // Code generated by "stringer -linecomment -type tag"; DO NOT EDIT. -package bson +package oldbson import "strconv" diff --git a/internal/bson/testdata/all.hex b/internal/bson2/oldbson/testdata/all.hex similarity index 100% rename from internal/bson/testdata/all.hex rename to internal/bson2/oldbson/testdata/all.hex diff --git a/internal/bson/testdata/array_all.hex b/internal/bson2/oldbson/testdata/array_all.hex similarity index 100% rename from internal/bson/testdata/array_all.hex rename to internal/bson2/oldbson/testdata/array_all.hex diff --git a/internal/bson/testdata/array_fuzz1.hex b/internal/bson2/oldbson/testdata/array_fuzz1.hex similarity index 100% rename from internal/bson/testdata/array_fuzz1.hex rename to internal/bson2/oldbson/testdata/array_fuzz1.hex diff --git a/internal/bson/testdata/handshake1.hex b/internal/bson2/oldbson/testdata/handshake1.hex similarity index 100% rename from internal/bson/testdata/handshake1.hex rename to internal/bson2/oldbson/testdata/handshake1.hex diff --git a/internal/bson/testdata/handshake2.hex b/internal/bson2/oldbson/testdata/handshake2.hex similarity index 100% rename from internal/bson/testdata/handshake2.hex rename to internal/bson2/oldbson/testdata/handshake2.hex diff --git a/internal/bson/testdata/handshake3.hex b/internal/bson2/oldbson/testdata/handshake3.hex similarity index 100% rename from internal/bson/testdata/handshake3.hex rename to internal/bson2/oldbson/testdata/handshake3.hex diff --git a/internal/bson/testdata/handshake4.hex b/internal/bson2/oldbson/testdata/handshake4.hex similarity index 100% rename from internal/bson/testdata/handshake4.hex rename to internal/bson2/oldbson/testdata/handshake4.hex diff --git a/internal/bson/timestamp.go b/internal/bson2/oldbson/timestamp.go similarity index 99% rename from internal/bson/timestamp.go rename to internal/bson2/oldbson/timestamp.go index a5c81c604aab..3dab9563ce54 100644 --- a/internal/bson/timestamp.go +++ b/internal/bson2/oldbson/timestamp.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "bufio" diff --git a/internal/bson/timestamp_test.go b/internal/bson2/oldbson/timestamp_test.go similarity index 98% rename from internal/bson/timestamp_test.go rename to internal/bson2/oldbson/timestamp_test.go index 19a0ccc1e6e0..b63f1a255955 100644 --- a/internal/bson/timestamp_test.go +++ b/internal/bson2/oldbson/timestamp_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bson +package oldbson import ( "testing"