-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
925b67a
commit a7403c9
Showing
58 changed files
with
1,580 additions
and
1,346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ docs/docs.go | |
docs/swagger.json | ||
docs/swagger.yaml | ||
dist/ | ||
ticker.db | ||
*.db | ||
site/ | ||
uploads/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ COPY ticker /ticker | |
USER ticker:ticker | ||
|
||
ENTRYPOINT ["/ticker"] | ||
CMD [ "run" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,10 @@ log_level: "error" | |
log_format: "json" | ||
# initiator is the email for the first admin user (see password in logs) | ||
initiator: "[email protected]" | ||
# database is the path to the bolt file | ||
database: "ticker.db" | ||
# configuration for the database | ||
database: | ||
type: "sqlite" # postgres, mysql, sqlite | ||
dsn: "ticker.db" # postgres: "host=localhost port=5432 user=ticker dbname=ticker password=ticker sslmode=disable" | ||
# secret used for JSON Web Tokens | ||
secret: "slorp-panfil-becall-dorp-hashab-incus-biter-lyra-pelage-sarraf-drunk" | ||
# telegram configuration | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,18 +16,21 @@ import ( | |
"github.com/stretchr/testify/mock" | ||
"github.com/systemli/ticker/internal/api/response" | ||
"github.com/systemli/ticker/internal/config" | ||
"github.com/systemli/ticker/internal/logger" | ||
"github.com/systemli/ticker/internal/storage" | ||
) | ||
|
||
var l = logger.NewLogrus("debug", "text") | ||
|
||
func init() { | ||
logrus.SetOutput(io.Discard) | ||
gin.SetMode(gin.TestMode) | ||
} | ||
|
||
func TestHealthz(t *testing.T) { | ||
c := config.NewConfig() | ||
s := &storage.MockTickerStorage{} | ||
r := API(c, s) | ||
s := &storage.MockStorage{} | ||
r := API(c, s, l) | ||
|
||
req := httptest.NewRequest(http.MethodGet, "/healthz", nil) | ||
w := httptest.NewRecorder() | ||
|
@@ -39,11 +42,11 @@ func TestHealthz(t *testing.T) { | |
|
||
func TestLoginNotSuccessful(t *testing.T) { | ||
c := config.NewConfig() | ||
s := &storage.MockTickerStorage{} | ||
s := &storage.MockStorage{} | ||
user := storage.User{} | ||
user.UpdatePassword("password") | ||
s.On("FindUserByEmail", mock.Anything).Return(user, nil) | ||
r := API(c, s) | ||
r := API(c, s, l) | ||
|
||
body := `{"username":"[email protected]","password":"WRONG"}` | ||
req := httptest.NewRequest(http.MethodPost, "/v1/admin/login", strings.NewReader(body)) | ||
|
@@ -62,11 +65,11 @@ func TestLoginNotSuccessful(t *testing.T) { | |
|
||
func TestLoginSuccessful(t *testing.T) { | ||
c := config.NewConfig() | ||
s := &storage.MockTickerStorage{} | ||
s := &storage.MockStorage{} | ||
user := storage.User{} | ||
user.UpdatePassword("password") | ||
s.On("FindUserByEmail", mock.Anything).Return(user, nil) | ||
r := API(c, s) | ||
r := API(c, s, l) | ||
|
||
body := `{"username":"[email protected]","password":"password"}` | ||
req := httptest.NewRequest(http.MethodPost, "/v1/admin/login", strings.NewReader(body)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.