Skip to content

Commit

Permalink
🚨test: update tests
Browse files Browse the repository at this point in the history
Refactor 'Jrp' slice to pointer slice in 'repository', 'generator',
'jrpwriter', and 'commands' for better performance and memory
management. Update mocks accordingly.
  • Loading branch information
yanosea committed Oct 8, 2024
1 parent 22d894a commit afb89f5
Show file tree
Hide file tree
Showing 17 changed files with 1,187 additions and 1,107 deletions.
715 changes: 383 additions & 332 deletions app/database/jrp/repository/repository_test.go

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions app/library/jrpwriter/jrpwriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestJrpWriter_WriteGenerateResultAsTable(t *testing.T) {
fields: fields{
t: t,
fnc: func() {
jrpWriter.WriteGenerateResultAsTable(osproxy.Stdout, []model.Jrp{})
jrpWriter.WriteGenerateResultAsTable(osproxy.Stdout, []*model.Jrp{})
},
capturer: capturer,
},
Expand All @@ -106,7 +106,7 @@ func TestJrpWriter_WriteGenerateResultAsTable(t *testing.T) {
fields: fields{
t: t,
fnc: func() {
jrps := []model.Jrp{
jrps := []*model.Jrp{
{
Phrase: "test",
Prefix: sqlProxy.StringToNullString("prefix"),
Expand All @@ -118,7 +118,7 @@ func TestJrpWriter_WriteGenerateResultAsTable(t *testing.T) {
},
capturer: capturer,
},
wantStdOut: "PHRASE\tPREFIX\tSUFFIX\tCREATED AT\ntest\tprefix\tsuffix\t9999-12-31 00:00:00\n\t\t\t\nTOTAL : 1\t\t\t\n",
wantStdOut: "ID\tPHRASE\tPREFIX\tSUFFIX\tCREATED AT\n0\ttest\tprefix\tsuffix\t9999-12-31 00:00:00\n\t\t\t\nTOTAL : 1\t\t\t\n",
wantStdErr: "",
wantErr: false,
},
Expand All @@ -127,7 +127,7 @@ func TestJrpWriter_WriteGenerateResultAsTable(t *testing.T) {
fields: fields{
t: t,
fnc: func() {
jrps := []model.Jrp{
jrps := []*model.Jrp{
{
Phrase: "test1",
Prefix: sqlProxy.StringToNullString("prefix1"),
Expand All @@ -145,7 +145,7 @@ func TestJrpWriter_WriteGenerateResultAsTable(t *testing.T) {
},
capturer: capturer,
},
wantStdOut: "PHRASE\tPREFIX\tSUFFIX\tCREATED AT\ntest1\tprefix1\tsuffix1\t9999-12-31 00:00:00\ntest2\tprefix2\tsuffix2\t9999-12-31 00:00:00\n\t\t\t\nTOTAL : 2\t\t\t\n",
wantStdOut: "ID\tPHRASE\tPREFIX\tSUFFIX\tCREATED AT\n0\ttest1\tprefix1\tsuffix1\t9999-12-31 00:00:00\n0\ttest2\tprefix2\tsuffix2\t9999-12-31 00:00:00\n\t\t\t\nTOTAL : 2\t\t\t\n",
wantStdErr: "",
wantErr: false,
},
Expand Down Expand Up @@ -216,7 +216,7 @@ func TestJrpWriter_WriteAsTable(t *testing.T) {
fields: fields{
t: t,
fnc: func() {
jrpWriter.WriteAsTable(osproxy.Stdout, []model.Jrp{})
jrpWriter.WriteAsTable(osproxy.Stdout, []*model.Jrp{})
},
capturer: capturer,
},
Expand All @@ -229,7 +229,7 @@ func TestJrpWriter_WriteAsTable(t *testing.T) {
fields: fields{
t: t,
fnc: func() {
jrps := []model.Jrp{
jrps := []*model.Jrp{
{
ID: 1,
Phrase: "test",
Expand All @@ -252,7 +252,7 @@ func TestJrpWriter_WriteAsTable(t *testing.T) {
fields: fields{
t: t,
fnc: func() {
jrps := []model.Jrp{
jrps := []*model.Jrp{
{
ID: 1,
Phrase: "test1",
Expand Down Expand Up @@ -315,7 +315,7 @@ func TestJrpWriter_writeTable(t *testing.T) {
tablewriterproxy.New(),
)
headers := []string{"phrase"}
rowFunc := func(jrp model.Jrp) []string {
rowFunc := func(jrp *model.Jrp) []string {
return []string{
jrp.Phrase,
}
Expand Down Expand Up @@ -350,7 +350,7 @@ func TestJrpWriter_writeTable(t *testing.T) {
fields: fields{
t: t,
fnc: func() {
jrpWriter.writeTable(osproxy.Stdout, []model.Jrp{}, headers, rowFunc)
jrpWriter.writeTable(osproxy.Stdout, []*model.Jrp{}, headers, rowFunc)
},
capturer: capturer,
},
Expand All @@ -362,7 +362,7 @@ func TestJrpWriter_writeTable(t *testing.T) {
fields: fields{
t: t,
fnc: func() {
jrps := []model.Jrp{
jrps := []*model.Jrp{
{
Phrase: "test",
},
Expand All @@ -378,7 +378,7 @@ func TestJrpWriter_writeTable(t *testing.T) {
fields: fields{
t: t,
fnc: func() {
jrps := []model.Jrp{
jrps := []*model.Jrp{
{
Phrase: "test1",
}, {
Expand Down
Loading

0 comments on commit afb89f5

Please sign in to comment.