-
Notifications
You must be signed in to change notification settings - Fork 1
Core dumps repository #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
base: develop
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| package entities | ||
|
|
||
| import "time" | ||
| import ( | ||
| "time" | ||
| ) | ||
|
|
||
| type CoreDumpStatus int | ||
|
|
||
|
|
@@ -12,53 +14,73 @@ const ( | |
| ) | ||
|
|
||
| type CoreDump struct { | ||
| osInfo *OSInfo | ||
| appInfo *AppInfo | ||
| status CoreDumpStatus | ||
| data string | ||
| timestamp time.Time | ||
| ID string | ||
| OsInfo *OSInfo | ||
| AppInfo *AppInfo | ||
| Status CoreDumpStatus | ||
| Data string | ||
| Timestamp time.Time | ||
| Extensions []Extension | ||
| } | ||
|
|
||
| type Extension struct { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Давай назовем CoreDumpExtension
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. allright |
||
| Key string | ||
| Value string | ||
| } | ||
|
|
||
| func NewCoreDump() *CoreDump { | ||
| return &CoreDump{} | ||
| } | ||
|
|
||
| func (c *CoreDump) OSInfo() *OSInfo { | ||
| return c.osInfo | ||
| func (c *CoreDump) GetOSInfo() *OSInfo { | ||
| return c.OsInfo | ||
| } | ||
|
|
||
| func (c *CoreDump) GetAppInfo() *AppInfo { | ||
| return c.AppInfo | ||
| } | ||
|
|
||
| func (c *CoreDump) AppInfo() *AppInfo { | ||
| return c.appInfo | ||
| func (c *CoreDump) GetStatus() CoreDumpStatus { | ||
| return c.Status | ||
| } | ||
|
|
||
| func (c *CoreDump) Status() CoreDumpStatus { | ||
| return c.status | ||
| func (c *CoreDump) GetData() string { | ||
| return c.Data | ||
| } | ||
|
|
||
| func (c *CoreDump) Data() string { | ||
| return c.data | ||
| func (c *CoreDump) GetTimestamp() time.Time { | ||
| return c.Timestamp | ||
| } | ||
|
|
||
| func (c *CoreDump) Timestamp() time.Time { | ||
| return c.timestamp | ||
| func (c *CoreDump) GetExtension(index int) *Extension { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. По индекс нам не придется получать
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. allright, deleted it |
||
| return &c.Extensions[index] | ||
| } | ||
|
|
||
| func (c *CoreDump) GetExtensions() *[]Extension { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Зачем указатель на слайс?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No pointer, allright. |
||
| return &c.Extensions | ||
| } | ||
|
|
||
| func (c *CoreDump) SetOSInfo(info *OSInfo) { | ||
| c.osInfo = info | ||
| c.OsInfo = info | ||
| } | ||
|
|
||
| func (c *CoreDump) SetAppInfo(info *AppInfo) { | ||
| c.appInfo = info | ||
| c.AppInfo = info | ||
| } | ||
|
|
||
| func (c *CoreDump) SetStatus(status CoreDumpStatus) { | ||
| c.status = status | ||
| c.Status = status | ||
| } | ||
|
|
||
| func (c *CoreDump) SetData(data string) { | ||
| c.data = data | ||
| c.Data = data | ||
| } | ||
|
|
||
| func (c *CoreDump) SetTimestamp(timestamp time.Time) { | ||
| c.timestamp = timestamp | ||
| c.Timestamp = timestamp | ||
| } | ||
|
|
||
| func (c *CoreDump) SetExtensions(key, value string) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Если метод называется SetExtensions он должен устанавливать все расширения, если говорим о добавление - это должно быть AddExtension
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. allright |
||
| extension := &Extension{Key: key, Value: value} | ||
| c.Extensions = append(c.Extensions, *extension) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,27 +10,34 @@ import ( | |
|
|
||
| func TestCoreDump(t *testing.T) { | ||
| coreDump := NewCoreDump() | ||
| require.Nil(t, coreDump.OSInfo()) | ||
| require.Nil(t, coreDump.AppInfo()) | ||
| require.Equal(t, ToDoCoreDumpStatus, coreDump.Status()) | ||
| require.Equal(t, time.Time{}, coreDump.Timestamp()) | ||
| require.Equal(t, 0, len(coreDump.Data())) | ||
| require.Nil(t, coreDump.GetOSInfo()) | ||
| require.Nil(t, coreDump.GetAppInfo()) | ||
| require.Equal(t, ToDoCoreDumpStatus, coreDump.GetStatus()) | ||
| require.Equal(t, time.Time{}, coreDump.GetTimestamp()) | ||
| require.Equal(t, 0, len(coreDump.GetData())) | ||
|
|
||
| osInfo := NewOSInfo() | ||
| appInfo := NewAppInfo() | ||
| timestamp := time.Now() | ||
| status := SolvedCoreDumpStatus | ||
| data := "server/internal/app/entities/core_dump_test.go@TestCoreDump:100" | ||
| extension := &Extension{ | ||
| Key: "key", | ||
| Value: "value", | ||
| } | ||
|
|
||
| coreDump.SetOSInfo(osInfo) | ||
| coreDump.SetAppInfo(appInfo) | ||
| coreDump.SetTimestamp(timestamp) | ||
| coreDump.SetStatus(status) | ||
| coreDump.SetData(data) | ||
| coreDump.SetExtensions(extension.Key, extension.Value) | ||
|
|
||
| assert.Equal(t, osInfo, coreDump.OSInfo()) | ||
| assert.Equal(t, appInfo, coreDump.AppInfo()) | ||
| assert.Equal(t, timestamp, coreDump.Timestamp()) | ||
| assert.Equal(t, status, coreDump.Status()) | ||
| assert.Equal(t, data, coreDump.Data()) | ||
| assert.Equal(t, osInfo, coreDump.GetOSInfo()) | ||
| assert.Equal(t, appInfo, coreDump.GetAppInfo()) | ||
| assert.Equal(t, timestamp, coreDump.GetTimestamp()) | ||
| assert.Equal(t, status, coreDump.GetStatus()) | ||
| assert.Equal(t, data, coreDump.GetData()) | ||
| assert.Equal(t, extension, coreDump.GetExtension(0)) | ||
| assert.Equal(t, true, len(*coreDump.GetExtensions()) > 0) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно не длину проверять, а контент внутри
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. allright |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,35 @@ | ||
| package entities | ||
|
|
||
| type OSInfo struct { | ||
| name string | ||
| version string | ||
| architecture string | ||
| Name string | ||
| Version string | ||
| Architecture string | ||
| } | ||
|
|
||
| func NewOSInfo() *OSInfo { | ||
| return &OSInfo{} | ||
| } | ||
|
|
||
| func (os *OSInfo) Name() string { | ||
| return os.name | ||
| func (os *OSInfo) GetName() string { | ||
| return os.Name | ||
| } | ||
|
|
||
| func (os *OSInfo) Version() string { | ||
| return os.version | ||
| func (os *OSInfo) GetVersion() string { | ||
| return os.Version | ||
| } | ||
|
|
||
| func (os *OSInfo) Architecture() string { | ||
| return os.architecture | ||
| func (os *OSInfo) GetArchitecture() string { | ||
| return os.Architecture | ||
| } | ||
|
|
||
| func (os *OSInfo) SetName(name string) { | ||
| os.name = name | ||
| os.Name = name | ||
| } | ||
|
|
||
| func (os *OSInfo) SetVersion(version string) { | ||
| os.version = version | ||
| os.Version = version | ||
| } | ||
|
|
||
| func (os *OSInfo) SetArchitecture(architecture string) { | ||
| os.architecture = architecture | ||
| os.Architecture = architecture | ||
| } |
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