From 796493a59a3d885379f611ecf31fd5606828856f Mon Sep 17 00:00:00 2001 From: Sergey Makarov Date: Thu, 24 Oct 2024 18:56:51 +0200 Subject: [PATCH] fix data race in text ctx [checktoberfest][hacktoberfest] --- pkg/allure/result.go | 6 ++---- pkg/allure/result_test.go | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/allure/result.go b/pkg/allure/result.go index 7f2ca02..dc8375d 100644 --- a/pkg/allure/result.go +++ b/pkg/allure/result.go @@ -65,7 +65,7 @@ func NewResult(testName, fullName string) *Result { ToPrint: true, } result.HistoryID = getMD5Hash(result.TestCaseID) - result.Labels = append(result.Labels, LanguageLabel(runtime.Version())) + result.AddLabel(LanguageLabel(runtime.Version())) result.Begin() return &result } @@ -126,13 +126,11 @@ func (result *Result) GetLabels(labelType LabelType) []*Label { // SetNewLabelMap Adds all passed in arguments `allure.Label` to the report func (result *Result) SetNewLabelMap(kv map[LabelType]string) { - result.m.Lock() - defer result.m.Unlock() - var labels []*Label for k, v := range kv { labels = append(labels, NewLabel(k, v)) } + result.AddLabel(labels...) } diff --git a/pkg/allure/result_test.go b/pkg/allure/result_test.go index 9425265..a102c9c 100644 --- a/pkg/allure/result_test.go +++ b/pkg/allure/result_test.go @@ -18,7 +18,6 @@ const ( ) func TestNewResult(t *testing.T) { - result := NewResult(testName, testFullName) now := GetNow()