mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
3a5753045e
rules_go added a SIGTERM handler that has a goroutine that survives the scope of the goleak check. Currently, the best known workaround is to ignore this goroutine. https://github.com/uber-go/goleak/issues/119 https://github.com/bazelbuild/rules_go/pull/3749 https://github.com/bazelbuild/rules_go/pull/3827#issuecomment-1894002120
47 lines
974 B
Go
47 lines
974 B
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package issues
|
|
|
|
import (
|
|
"bytes"
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"go.uber.org/goleak"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
goleak.VerifyTestMain(m, goleak.IgnoreAnyFunction("github.com/bazelbuild/rules_go/go/tools/bzltestutil.RegisterTimeoutHandler.func1"))
|
|
}
|
|
|
|
func TestMap(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
m := New()
|
|
assert.Equal(0, len(m))
|
|
assert.False(m.FileHasIssues("file1"))
|
|
m.Set("file1", map[string][]error{
|
|
"rule1": {errors.New("r1_issue1"), errors.New("r1_issue2")},
|
|
"rule2": {errors.New("r2_issue1")},
|
|
})
|
|
assert.Equal(3, m.IssuesPerFile("file1"))
|
|
assert.True(m.FileHasIssues("file1"))
|
|
|
|
// let report write to a buffer
|
|
b := new(bytes.Buffer)
|
|
m.Report(b)
|
|
rep := b.String()
|
|
assert.Equal(rep, `File file1 (3 issues total):
|
|
Rule rule1 (2 issues total):
|
|
r1_issue1
|
|
r1_issue2
|
|
Rule rule2 (1 issues total):
|
|
r2_issue1
|
|
`)
|
|
}
|