Closed Dmaddu closed 2 years ago
Hello there,
I have a function that accepts Postgres connection URL, instead of sql.DB. With db, mock, err := sqlmock.New() I am getting db of type sql.DB
db, mock, err := sqlmock.New()
Is there any way to get the connection URL from *sql.DB so that I can mock the queries that trigger in my function.
my method looks like as below
func MyFunc(dbconn string){ ... }
Try NewWithDSN.
Hi, It seems @dolmen answered your question & this thread has been inactive for a while so I will be closing this.
Hello there,
I have a function that accepts Postgres connection URL, instead of sql.DB. With
db, mock, err := sqlmock.New()
I am getting db of type sql.DBIs there any way to get the connection URL from *sql.DB so that I can mock the queries that trigger in my function.
my method looks like as below
func MyFunc(dbconn string){ ... }