Hello,
I did that but when I run the test registration this error occurred:
=== RUN TestRegistration
— FAIL: TestRegistration (0.01s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x260 pc=0xb65a87]
goroutine 20 [running]:
testing.tRunner.func1.1(0x1212840, 0x1fe9a70)
/usr/local/go/src/testing/testing.go:940 +0x2f5
testing.tRunner.func1(0xc00045b9e0)
/usr/local/go/src/testing/testing.go:943 +0x3f9
panic(0x1212840, 0x1fe9a70)
/usr/local/go/src/runtime/panic.go:969 +0x166
go.mongodb.org/mongo-driver/mongo.newDatabase(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0004ab550)
/home/carlos/go/pkg/mod/go.mongodb.org/[email protected]/mongo/database.go:37 +0x67
go.mongodb.org/mongo-driver/mongo.(*Client).Database(…)
/home/carlos/go/pkg/mod/go.mongodb.org/[email protected]/mongo/client.go:418
free5gc/lib/MongoDBLibrary.RestfulAPIPutOne(0x142543e, 0x3e, 0xc000463980, 0xc0004dd350, 0xc0004d9f48)
/home/carlos/free5gc_mongo/lib/MongoDBLibrary/api_mongoDB.go:73 +0x68
free5gc/src/test.InsertAuthSubscriptionToMongoDB(0x13f3a82, 0x12, 0x13d8f87, 0x6, 0xc0004adb60, 0x13e6ec4, 0xc, 0x13d6435, 0x4, 0x0, …)
/home/carlos/free5gc_mongo/src/test/mongodb.go:30 +0x1ba
free5gc/src/test_test.TestRegistration(0xc00045b9e0)
/home/carlos/free5gc_mongo/src/test/registration_test.go:76 +0x795
testing.tRunner(0xc00045b9e0, 0x1435d18)
/usr/local/go/src/testing/testing.go:991 +0xdc
created by testing.(*T).Run
/usr/local/go/src/testing/testing.go:1042 +0x357
exit status 2
FAIL free5gc/src/test 0.027s
Using debugging tools I have found that even though mongodB has been initialized by the NRF in the core, the test doesn’t seem to have a conection with the DB. Client and mongoDBName variables are null, therefore it doesn’t know where to put or extract the data.
What I have done to solve this is to put the following lines at the beginning of the test so it initializes again the DB, it have seemed to worked but I don’t know if it is correct:
MongoDBLibrary.SetMongoDB(factory.NrfConfig.Configuration.MongoDBName
Thanks,