aboutsummaryrefslogtreecommitdiff
path: root/db/db_test.go
blob: 0481915a311b4af4946cc04ab251c82ab8fcb8a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package db

import "testing"

func TestInit(t *testing.T) {
	Init(DBConfig{"localhost:5432", "cryptoportfolio", "cryptoportfolio", "cryptoportfolio-dev"})
}

func TestUpdateUser(t *testing.T) {
	Init(DBConfig{"localhost:5432", "cryptoportfolio", "cryptoportfolio", "cryptoportfolio-dev"})
	t.Log(InsertUser(&User{Email: "j@test.com", PasswordHash: "yp"}))
	err := InsertUser(&User{Email: "t2@test.com", PasswordHash: "yp"})

	t.Log(err, IsDup(err))

	t.Log(GetUserByEmail("testyo"))
}

func TestMarketConfig(t *testing.T) {
	Init(DBConfig{"localhost:5432", "cryptoportfolio", "cryptoportfolio", "cryptoportfolio-dev"})

	config := MarketConfig{UserId: 1, MarketName: "poloniex"}
	config.Config = make(map[string]string)

	config.Config["secret"] = "key"

	t.Log(InsertMarketConfig(&config))
	t.Log(config)

	t.Log(GetUserMarketConfig(1, "poloniex"))

	config.Config["secret2"] = "key2"
	t.Log(SetUserMarketConfig(1, "poloniex", config.Config))
	t.Log(SetUserMarketConfig(1, "bifinance", config.Config))
}