Invalid Mongo Server URI Port
Closed this issue · 1 comments
artahc commented
func TestMain(m *testing.M) {
opts := &memongo.Options{
MongoVersion: "7.0.2",
MongodBin: "/opt/homebrew/bin/mongod",
Logger: log.Default(),
LogLevel: 2,
Port: 27018,
StartupTimeout: time.Second * 30,
}
if runtime.GOARCH == "arm64" {
if runtime.GOOS == "darwin" {
opts.DownloadURL = fmt.Sprintf("https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-%s.tgz", MONGODB_VERSION)
}
}
mongoServer, err := memongo.StartWithOptions(opts)
if err != nil {
log.Fatal(err)
}
defer mongoServer.Stop()
os.Exit(m.Run())
}
mongoServer.URI always returns mongodb://localhost:0
instead of given port number
Edit:
I'm using the latest commit b8467444e40c09e725bd81372d236a5a948694f2
because of removal ephemeralForTest
on mongodb version which I'm using
artahc commented
Uh, actually I was wrong.
I was trying to initialize memongo.Server to global variable to be shared between test, but this line right here, doesn't really assign it my global variable,
mongoServer, err := memongo.StartWithOptions(opts)
so my global variable is actually empty, thus the port returns an empty value (0).