aboutsummaryrefslogtreecommitdiff
path: root/db/db_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'db/db_test.go')
-rw-r--r--db/db_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/db/db_test.go b/db/db_test.go
new file mode 100644
index 0000000..0481915
--- /dev/null
+++ b/db/db_test.go
@@ -0,0 +1,35 @@
1package db
2
3import "testing"
4
5func TestInit(t *testing.T) {
6 Init(DBConfig{"localhost:5432", "cryptoportfolio", "cryptoportfolio", "cryptoportfolio-dev"})
7}
8
9func TestUpdateUser(t *testing.T) {
10 Init(DBConfig{"localhost:5432", "cryptoportfolio", "cryptoportfolio", "cryptoportfolio-dev"})
11 t.Log(InsertUser(&User{Email: "j@test.com", PasswordHash: "yp"}))
12 err := InsertUser(&User{Email: "t2@test.com", PasswordHash: "yp"})
13
14 t.Log(err, IsDup(err))
15
16 t.Log(GetUserByEmail("testyo"))
17}
18
19func TestMarketConfig(t *testing.T) {
20 Init(DBConfig{"localhost:5432", "cryptoportfolio", "cryptoportfolio", "cryptoportfolio-dev"})
21
22 config := MarketConfig{UserId: 1, MarketName: "poloniex"}
23 config.Config = make(map[string]string)
24
25 config.Config["secret"] = "key"
26
27 t.Log(InsertMarketConfig(&config))
28 t.Log(config)
29
30 t.Log(GetUserMarketConfig(1, "poloniex"))
31
32 config.Config["secret2"] = "key2"
33 t.Log(SetUserMarketConfig(1, "poloniex", config.Config))
34 t.Log(SetUserMarketConfig(1, "bifinance", config.Config))
35}