You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
567 B
24 lines
567 B
package base
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
)
|
|
|
|
func TestGetID(t *testing.T) {
|
|
|
|
type DocWithObjectID struct {
|
|
ObjectID `bson:"_id" json:"_id" collection:"1"`
|
|
}
|
|
type DocWithObject struct {
|
|
Object `bson:"_id" json:"_id" collection:"2"`
|
|
}
|
|
type DocWithString struct {
|
|
String `bson:"_id" json:"_id" collection:"3"`
|
|
}
|
|
|
|
GetID(&DocWithObjectID{ObjectID: ObjectID([12]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2})})
|
|
GetID(&DocWithObject{Object: Object(primitive.D{{"1", "2"}})})
|
|
GetID(&DocWithString{String: String("foobar")})
|
|
}
|
|
|