-
Notifications
You must be signed in to change notification settings - Fork 1
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
Core dumps repository #1
base: develop
Are you sure you want to change the base?
Conversation
d1bc507
to
2fd163d
Compare
feat: CoreDumpsRepository implementation and test
e3118de
to
e044620
Compare
server/internal/app/configuration.go
Outdated
ServerAddress = os.Getenv("CRASHER_SERVER_ADDRESS") | ||
|
||
ServerAddress = os.Getenv("CRASHER_SERVER_ADDRESS") | ||
CtxTimeout = os.Getenv("CRASHER_DATABASE_TIMEOUTgit") |
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.
git - что-то лишнее)
И давай название переменной сделаем DatabaseTimeout
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.
Right)
CRASHER_DATABASE_TIMEOUT or DATABASE_TIMEOUT?
status CoreDumpStatus | ||
data string | ||
timestamp time.Time | ||
ID primitive.ObjectID |
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.
entity - ничего не должен знать о БД, в будущем замена БД должна быть бесшовной
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.
So what type for ID then? int?
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.
I changed ID to string type as its in the method parameter and API scheme.
How to set a unique ID when creating a dump? We are missing a string ID setter...
Extensions []Extensions | ||
} | ||
|
||
type Extensions struct { |
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.
Extension давай только, а вот выше давай так оставим Extensions []Extension
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.
allright
Status CoreDumpStatus | ||
Data string | ||
Timestamp time.Time | ||
Extensions []Extensions |
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.
Геттер и сеттер еще только давай сделаем
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.
allright
@@ -0,0 +1,43 @@ | |||
package entities |
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.
Внутри entities не должно быть никакого mongo - стоит это вынести к mongodb
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.
done
server/internal/app/repositories/mongodb_repository/core_dumps_repository_test.go
Show resolved
Hide resolved
} | ||
} | ||
|
||
func Test_DeleteCoreDump(t *testing.T) { |
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.
Для DeleteAll еще нужен
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.
done
server/internal/app/repositories/mongodb_repository/core_dumps_repository_test.go
Outdated
Show resolved
Hide resolved
server/internal/app/repositories/mongodb_repository/core_dumps_repository_test.go
Outdated
Show resolved
Hide resolved
server/internal/app/repositories/mongodb_repository/core_dumps_repository_test.go
Show resolved
Hide resolved
6cf1acd
to
ae80ef3
Compare
server/internal/app/configuration.go
Outdated
ServerAddress = os.Getenv("CRASHER_SERVER_ADDRESS") | ||
|
||
ServerAddress = os.Getenv("CRASHER_SERVER_ADDRESS") | ||
CtxTimeout = parseEnvOrDefaultValue("CRASHER_DATABASE_TIMEOUT", "5") |
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.
Название переменной, как и говорил, давай сделаем DatabaseTimeout
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.
Не надо здесь парсить - парсить будем в main-e
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.
ok
} | ||
|
||
func (c *CoreDump) Timestamp() time.Time { | ||
return c.timestamp | ||
func (c *CoreDump) GetExtension(index int) *Extension { |
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.
По индекс нам не придется получать
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.
allright, deleted it
c.Timestamp = timestamp | ||
} | ||
|
||
func (c *CoreDump) SetExtensions(key, value string) { |
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.
Если метод называется SetExtensions он должен устанавливать все расширения, если говорим о добавление - это должно быть AddExtension
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.
allright
Extensions []Extension | ||
} | ||
|
||
type Extension struct { |
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.
Давай назовем CoreDumpExtension
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.
allright
return &c.Extensions[index] | ||
} | ||
|
||
func (c *CoreDump) GetExtensions() *[]Extension { |
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.
Зачем указатель на слайс?
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.
No pointer, allright.
server/internal/app/repositories/mongodb_repository/core_dumps_repository_test.go
Show resolved
Hide resolved
error: errors.New("error enter dump id"), | ||
}, | ||
} | ||
for _, test := range tests { |
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.
Забыл
rand.Seed(time.Now().Unix()) | ||
} | ||
|
||
func generateRandomSliceOfCoreDumps(quantity int) []entities.CoreDump { |
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.
Забыл
res := filter["appinfo.name"] | ||
|
||
require.Equal(t, "app", res) | ||
require.Equal(t, true, len(filter) > 0) |
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.
Нужно проверять содержимое фильтров
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.
И для тестов ниже
setter(filter, options) | ||
res := filter["appinfo.name"] | ||
|
||
require.Equal(t, "app", res) |
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.
Здесь нужны ассерты, а не require
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.
И для тестов ниже
634a3ef
to
ed81e3f
Compare
No description provided.