-
Notifications
You must be signed in to change notification settings - Fork 7
Setting up test environment #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8a0efce
5868342
837b71b
7adf59b
3ef94e6
2cef8ff
7153425
3bc0a8f
0116a5a
3edaaf4
2141ccb
c55fa6a
c8616f6
bd1a961
b5e1a99
47ec1c2
6299bb1
b8f9b5a
330a98b
9123d1f
8ba021a
ec25cd0
e4f687e
06ac263
6cae7d1
00c8829
d6f8408
484bc87
0388f73
5cfb730
0b0b78a
ac40a67
2e3aa8a
a7a2edb
fa4f578
5042dbc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: MySQLAdapter test | ||
on: push | ||
|
||
jobs: | ||
# Label of the container job | ||
container-job: | ||
# Containers must run in Linux based operating systems | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
mysql: | ||
image: mysql:latest | ||
env: | ||
MYSQL_DATABASE: searchlight_tests | ||
MYSQL_HOST: 127.0.0.1 | ||
MYSQL_USER: mysql | ||
MYSQL_PASSWORD: mysql | ||
MYSQL_ROOT_PASSWORD: rootpass | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: julia-actions/setup-julia@latest | ||
with: | ||
version: '1.7.1' | ||
arch: 'x64' | ||
- uses: julia-actions/julia-buildpkg@master | ||
- name: Install SearchLight and SearchLightMySQL | ||
run: | | ||
pwd | ||
julia -e 'using Pkg; Pkg.add(url="https://github.com/GenieFramework/SearchLight.jl.git")' | ||
julia -e 'using Pkg; Pkg.add(url="https://github.com/GenieFramework/SearchLightMySQL.jl.git")' | ||
julia -e 'import Pkg; Pkg.add("SafeTestsets")' | ||
julia -e 'using Pkg; Pkg.activate(".")' | ||
julia -e 'using Pkg; Pkg.resolve()' | ||
shell: bash | ||
- uses: julia-actions/julia-runtest@master |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[deps] | ||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" | ||
SearchLight = "340e8cb6-72eb-11e8-37ce-c97ebeb32050" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
TestSetExtensions = "98d24dd4-01ad-11ea-1b02-c9a08f80db04" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module CreateTableUsers | ||
|
||
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table | ||
|
||
function up() | ||
create_table(:users) do | ||
[ | ||
primary_key() | ||
column(:username, :string, limit = 100) | ||
column(:password, :string, limit = 100) | ||
column(:name, :string, limit = 100) | ||
column(:email, :string, limit = 100) | ||
] | ||
end | ||
|
||
add_index(:users, :username) | ||
end | ||
|
||
function down() | ||
drop_table(:users) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module CreateTableRoles | ||
|
||
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table | ||
|
||
function up() | ||
create_table(:roles) do | ||
[ | ||
primary_key() | ||
column(:name, :string, limit = 100) | ||
] | ||
end | ||
|
||
add_index(:roles, :name) | ||
end | ||
|
||
function down() | ||
drop_table(:roles) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module CreateTableAbilities | ||
|
||
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table | ||
|
||
function up() | ||
create_table(:abilities) do | ||
[ | ||
primary_key() | ||
column(:name, :string, limit = 100) | ||
] | ||
end | ||
|
||
add_index(:abilities, :name) | ||
end | ||
|
||
function down() | ||
drop_table(:abilities) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module CreateTableRolesUsers | ||
|
||
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table | ||
|
||
function up() | ||
create_table(:rolesusers) do | ||
[ | ||
primary_key() | ||
column(:roles_id, :int) | ||
column(:users_id, :int) | ||
] | ||
end | ||
|
||
add_index(:rolesusers, :roles_id) | ||
add_index(:rolesusers, :users_id) | ||
end | ||
|
||
function down() | ||
drop_table(:rolesusers) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module CreateTableAbilitiesRoles | ||
|
||
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table | ||
|
||
function up() | ||
create_table(:abilitiesroles) do | ||
[ | ||
primary_key() | ||
column(:abilities_id, :int) | ||
column(:roles_id, :int) | ||
] | ||
end | ||
|
||
add_index(:abilitiesroles, :abilities_id) | ||
add_index(:abilitiesroles, :roles_id) | ||
end | ||
|
||
function down() | ||
drop_table(:abilitiesroles) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
module TestModels | ||
|
||
using SearchLight | ||
|
||
######## Model from Genie-Searchligth-example-app extracted ############ | ||
export Book, BookWithInterns | ||
using SearchLight, Dates | ||
|
||
######## Model from Genie-Searchligth-example-app extracted ############ | ||
export Callback | ||
export seed, fields_to_store | ||
|
||
mutable struct Book <: AbstractModel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could use the newer syntax based on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The @kwdef phrase is only needed if you want to specify default values by creating instances of a struct. If this isn't needed because you set the values of the fields later you can use it in the form used here. But I know what you mean. |
||
|
||
### FIELDS | ||
id::DbId | ||
title::String | ||
author::String | ||
cover::String | ||
|
||
### VALIDATION | ||
# validator::ModelValidator | ||
|
||
### CALLBACKS | ||
# before_save::Function | ||
# after_save::Function | ||
# on_save::Function | ||
# on_find::Function | ||
# after_find::Function | ||
|
||
### SCOPES | ||
# scopes::Dict{Symbol,Vector{SearchLight.SQLWhereEntity}} | ||
|
||
### constructor | ||
Book(; | ||
### FIELDS | ||
id = DbId(), | ||
title = "", | ||
author = "", | ||
cover = "", | ||
|
||
### VALIDATION | ||
# validator = ModelValidator([ | ||
# ValidationRule(:title, BooksValidator.not_empty) | ||
# ]), | ||
|
||
### CALLBACKS | ||
# before_save = (m::Todo) -> begin | ||
# @info "Before save" | ||
# end, | ||
# after_save = (m::Todo) -> begin | ||
# @info "After save" | ||
# end, | ||
# on_save = (m::Todo, field::Symbol, value::Any) -> begin | ||
# @info "On save" | ||
# end, | ||
# on_find = (m::Todo, field::Symbol, value::Any) -> begin | ||
# @info "On find" | ||
# end, | ||
# after_find = (m::Todo) -> begin | ||
# @info "After find" | ||
# end, | ||
|
||
### SCOPES | ||
# scopes = Dict{Symbol,Vector{SearchLight.SQLWhereEntity}}() | ||
|
||
) = new(id, title, author, cover ### FIELDS | ||
# validator, ### VALIDATION | ||
# before_save, after_save, on_save, on_find, after_find ### CALLBACKS | ||
# scopes ### SCOPES | ||
) | ||
end | ||
|
||
mutable struct BookWithInterns <: AbstractModel | ||
|
||
### FIELDS | ||
id::DbId | ||
title::String | ||
author::String | ||
cover::String | ||
|
||
### VALIDATION | ||
# validator::ModelValidator | ||
|
||
### CALLBACKS | ||
# before_save::Function | ||
# after_save::Function | ||
# on_save::Function | ||
# on_find::Function | ||
# after_find::Function | ||
|
||
### SCOPES | ||
# scopes::Dict{Symbol,Vector{SearchLight.SQLWhereEntity}} | ||
|
||
### constructor | ||
BookWithInterns(; | ||
### FIELDS | ||
id = DbId(), | ||
title = "", | ||
author = "", | ||
cover = "", | ||
|
||
### VALIDATION | ||
# validator = ModelValidator([ | ||
# ValidationRule(:title, BooksValidator.not_empty) | ||
# ]), | ||
|
||
### CALLBACKS | ||
# before_save = (m::Todo) -> begin | ||
# @info "Before save" | ||
# end, | ||
# after_save = (m::Todo) -> begin | ||
# @info "After save" | ||
# end, | ||
# on_save = (m::Todo, field::Symbol, value::Any) -> begin | ||
# @info "On save" | ||
# end, | ||
# on_find = (m::Todo, field::Symbol, value::Any) -> begin | ||
# @info "On find" | ||
# end, | ||
# after_find = (m::Todo) -> begin | ||
# @info "After find" | ||
# end, | ||
|
||
### SCOPES | ||
# scopes = Dict{Symbol,Vector{SearchLight.SQLWhereEntity}}() | ||
|
||
) = new("bookwithinterns", "id", Symbol[], ### INTERNALS | ||
id, title, author, cover ### FIELDS | ||
# validator, ### VALIDATION | ||
# before_save, after_save, on_save, on_find, after_find ### CALLBACKS | ||
# scopes ### SCOPES | ||
) | ||
end | ||
|
||
Base.@kwdef mutable struct Callback <: AbstractModel | ||
id::DbId = DbId() | ||
title::String = "" | ||
indicator::Bool = true | ||
created_at::String = string(Dates.now()) | ||
# callbacks | ||
before_save::Function = (m::Callback) -> begin | ||
@info "Do something before saving" | ||
end | ||
after_save::Function = (m::Callback) -> begin | ||
@info "Do something after saving" | ||
end | ||
end | ||
|
||
function seed() | ||
BillGatesBooks = [ | ||
("The Best We Could Do", "Thi Bui"), | ||
("Evicted: Poverty and Profit in the American City", "Matthew Desmond"), | ||
("Believe Me: A Memoir of Love, Death, and Jazz Chickens", "Eddie Izzard"), | ||
("The Sympathizer!", "Viet Thanh Nguyen"), | ||
("Energy and Civilization, A History", "Vaclav Smil") | ||
] | ||
end | ||
|
||
end ### End Module |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
env: dev | ||
|
||
dev: | ||
adapter: MySQL | ||
host: 127.0.0.1 | ||
port: 3306 | ||
database: searchlight_tests | ||
username: mysql | ||
password: mysql | ||
|
||
config: | ||
log_queries: true | ||
log_level: :debug |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cd(@__DIR__) | ||
|
||
using Pkg | ||
|
||
using Test, TestSetExtensions, SafeTestsets | ||
using SearchLight | ||
using SearchLightMySQL | ||
using Dates | ||
|
||
# @testset ExtendedTestSet "SearchLight PostgreSQL adapter tests" begin | ||
# @includetests ARGS | ||
# end | ||
|
||
# run a simple connect test for the first time | ||
|
||
@testset ExtendedTestSet "SearchLight tests" begin | ||
@includetests ARGS | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened to this file? Why so many dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file is deleted