Skip to content

Commit 91a6860

Browse files
committed
refactor: introduce new fn for creating explaingen with error, update tests
1 parent b2384a2 commit 91a6860

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

translation.go

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ func (gen *ExplainGenerator) CreateSection(name string) *ExplainGenerator {
3939
return gen.Sections[name]
4040
}
4141

42+
func NewExplainGeneratorForError(name string) *ExplainGenerator {
43+
return &ExplainGenerator{
44+
ErrorName: name,
45+
}
46+
}
47+
4248
type BugFixSuggestion struct {
4349
Title string
4450
Steps []*BugFixStep

translation_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
func TestExplainGenerator(t *testing.T) {
1212
t.Run("errorName", func(t *testing.T) {
13-
gen := &lib.ExplainGenerator{ErrorName: "TestError"}
13+
gen := lib.NewExplainGeneratorForError("TestError")
1414

1515
if gen.ErrorName != "TestError" {
1616
t.Errorf("Expected 'TestError', got %s", gen.ErrorName)
@@ -65,7 +65,7 @@ func TestExplainGenerator(t *testing.T) {
6565
})
6666

6767
t.Run("Append with newline", func(t *testing.T) {
68-
gen := &lib.ExplainGenerator{ErrorName: "TestError"}
68+
gen := lib.NewExplainGeneratorForError("TestError")
6969
gen.Add("This is a simple error explanation.\n")
7070
gen.Add("This is another error message.")
7171

0 commit comments

Comments
 (0)