Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tank
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
tank
Commits
c86d9387
Commit
c86d9387
authored
6 years ago
by
Christian Pointner
Browse files
Options
Downloads
Patches
Plain Diff
fix store tests
parent
9d04b23e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
store/store_test.go
+19
-23
19 additions, 23 deletions
store/store_test.go
with
19 additions
and
23 deletions
store/store_test.go
+
19
−
23
View file @
c86d9387
...
...
@@ -39,9 +39,12 @@ var (
testBasePath
=
"run/aura-tank_testing"
testPublicDirPath
=
filepath
.
Join
(
testBasePath
,
publicGroupName
)
testDBType
=
"mysql"
testDBConnection
=
"tank:aura@tcp(127.0.0.1:3306)/tank?charset=utf8&parseTime=True&loc=Local"
// testDBType = "postgres"
// testDBConnection = "host=127.0.0.1 port=5432 user=tank dbname=tank password=aura sslmode=disable"
testDBHost
=
"127.0.0.1"
testDBPort
=
uint16
(
0
)
testDBUsername
=
"tank"
testDBPassword
=
"aura"
testDBDB
=
"tank"
testGroup1
=
"test1"
testGroup2
=
"test2"
testUser1
=
"user1"
...
...
@@ -56,11 +59,20 @@ var (
testFileTitle2
=
"this is not two title's"
)
func
testDBConfig
()
(
cfg
DBConfig
)
{
cfg
.
Type
=
testDBType
cfg
.
Host
=
testDBHost
cfg
.
Port
=
testDBPort
cfg
.
Username
=
testDBUsername
cfg
.
Password
=
testDBPassword
cfg
.
DB
=
testDBDB
return
}
func
newTestStore
(
t
*
testing
.
T
)
*
Store
{
cfg
:=
Config
{}
cfg
.
BasePath
=
testBasePath
cfg
.
DB
.
Type
=
testDBType
cfg
.
DB
.
Connection
=
testDBConnection
cfg
.
DB
=
testDBConfig
()
// TODO: drop database (all tables and constrains)
...
...
@@ -79,7 +91,6 @@ func TestMain(m *testing.M) {
testBasePath
=
fmt
.
Sprintf
(
"/run/user/%s/aura-tank_testing"
,
u
.
Uid
)
os
.
RemoveAll
(
testBasePath
)
testPublicDirPath
=
filepath
.
Join
(
testBasePath
,
publicGroupName
)
// testDBConnection = filepath.Join(testBasePath, ".db.sqlite")
os
.
Exit
(
m
.
Run
())
}
...
...
@@ -91,8 +102,7 @@ func TestOpen(t *testing.T) {
// base-path is non-existing directory
cfg
:=
Config
{}
cfg
.
BasePath
=
"/nonexistend/"
cfg
.
DB
.
Type
=
testDBType
cfg
.
DB
.
Connection
=
testDBConnection
cfg
.
DB
=
testDBConfig
()
if
_
,
err
:=
NewStore
(
cfg
);
err
==
nil
{
t
.
Fatalf
(
"opening store in nonexisting directory should throw an error"
)
}
...
...
@@ -101,19 +111,6 @@ func TestOpen(t *testing.T) {
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
/// exisiting but non-database file (only possible with sqlite...)
// if f, err := os.Create(testDBConnection); err != nil {
// t.Fatalf("unexpected error: %v", err)
// } else {
// io.WriteString(f, "this is not a sqlite db.")
// f.Close()
// }
// if _, err := NewStore(cfg); err == nil {
// t.Fatalf("opening store using a invalid database should throw an error")
// }
/// create new db and reopen it
// os.Remove(testDBConnection)
store
,
err
:=
NewStore
(
cfg
)
if
err
!=
nil
{
t
.
Fatalf
(
"creating new store failed: %v"
,
err
)
...
...
@@ -145,8 +142,7 @@ func TestOpen(t *testing.T) {
func
TestMigrations
(
t
*
testing
.
T
)
{
cfg
:=
Config
{}
cfg
.
BasePath
=
testBasePath
cfg
.
DB
.
Type
=
testDBType
cfg
.
DB
.
Connection
=
testDBConnection
cfg
.
DB
=
testDBConfig
()
// os.Remove(testDBConnection)
store
,
err
:=
NewStore
(
cfg
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment