Skip to content

Commit

Permalink
testing mysql and postgresql JuliaDatabases#1
Browse files Browse the repository at this point in the history
testing the github secrets
  • Loading branch information
Farreeda committed Jul 3, 2023
1 parent fdef69c commit b18efea
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ jobs:
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
env:

POSTGRES_USER = {{secrets.POSTGRES_USER}}
POSTGRES_HOST = {{secrets.POSTGRES_HOST}}
POSTGRES_PORT = {{secrets.POSTGRES_PORT}}
POSTGRES_PASSWORD = {{secrets.POSTGRES_PASSWORD}}
MYSQL_USER = {{secrets.MYSQL_USER}}
MYSQL_HOST = {{secrets.MYSQL_HOST}}
MYSQL_PORT = {{secrets.MYSQL_PORT}}
MYSQL_PASSWORD = {{secrets.MYSQL_PASSWORD}}

- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
Expand Down
7 changes: 5 additions & 2 deletions src/mysql.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
function _dbconnect(conn_obj::Type{MySQL.Connection}, kwargs)
function _dbconnect(conn_obj::Type{MySQL.Connection}, host::String, user::String, password::String; db::String="", port::Integer=3306, unix_socket::Union{Nothing,String}=nothing, client_flag=API.CLIENT_MULTI_STATEMENTS, opts = Dict())

return DBInterface.connect(conn_obj; kwargs...)
if unix_socket == nothing
unix_socket = API.MYSQL_DEFAULT_SOCKET
end

return DBInterface.connect(conn_obj,host, user, password, db=db, port=port, unix_socket=unix_socket, client_flag=client_flag, opts=opts )
end
3 changes: 2 additions & 1 deletion src/postgresql.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Dispatch for LibPQ interface to DBInterface `connect` function; not supported in
DBInterface.connect(::Type{LibPQ.Connection}, args...; kws...) =
LibPQ.Connection(args...; kws...)

function _dbconnect(conn_obj::Type{LibPQ.Connection}; kwargs...)
function _dbconnect(conn_obj::Type{LibPQ.Connection}, host::String, user::String, password::String; db::String="", port::Integer=5432, unix_socket::Union{Nothing,String}=nothing, client_flag=API.CLIENT_MULTI_STATEMENTS, opts = Dict())

conn_string = ""
for k in kwargs
conn_string = conn_string * "$(string(k.first))=$(k.second) "
Expand Down
22 changes: 22 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using Test, DataFrames, SQLite
using MySQL,SQLite, MySQL.API, LibPQ


include("../src/sqlite.jl")
include("../src/mysql.jl")
include("../src/postgresql.jl")

@testset "_dbconnect function for SQLite" begin

Expand All @@ -11,3 +16,20 @@ include("../src/sqlite.jl")
@test out == expected_output

end

@testset "_dbconnect function for MySQL" begin

conn = _dbconnect(MySQL.Connection, ENV['MYSQL_HOST'], ENV['MYSQL_USER'], ENV['MYSQL_PASSWORD'], db="MySQL")

@test typeof(conn) == MySQL.Connection
@test isopen(conn)
close(conn)

end

@testset "_dbconnect function for LibPQ" begin

conn= _dbconnect(LibPQ.Connection, ENV['POSTGRES_HOST'], ENV['POSTGRES_USER'], ENV['POSTGRES_PASSWORD'], db = "mimic")
@test @isdefined conn

end

0 comments on commit b18efea

Please sign in to comment.