Fix #123: Deduplicate result errors

This commit is contained in:
TwinProduction
2021-06-05 18:50:24 -04:00
parent 5e00752c5a
commit 8997eeef05
5 changed files with 50 additions and 8 deletions

21
core/result_test.go Normal file
View File

@ -0,0 +1,21 @@
package core
import (
"testing"
)
func TestResult_AddError(t *testing.T) {
result := &Result{}
result.AddError("potato")
if len(result.Errors) != 1 {
t.Error("should've had 1 error")
}
result.AddError("potato")
if len(result.Errors) != 1 {
t.Error("should've still had 1 error, because a duplicate error was added")
}
result.AddError("tomato")
if len(result.Errors) != 2 {
t.Error("should've had 2 error")
}
}