1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/pkg/log/errors_test.go
Oliver Nocon d8444d51f2
Add possibility to add category to failures (#1692)
* Add possibility to add category to failures

It is now possible to set the error category within the flow.
When exiting the program the error category can be used.

There is  a convenience function available for exiting with a previously set category,
for example

```
log.SetErrorCategory(log.ErrorCompliance)
...
log.FatalError(err, "configuration error")
```

* extend test

* go mod tidy

* add missing comment

* update information about error categories

* Update DEVELOPMENT.md
2020-06-22 08:21:38 +02:00

20 lines
386 B
Go

package log
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSetErrorCategory(t *testing.T) {
SetErrorCategory(ErrorCustom)
assert.Equal(t, errorCategory, ErrorCustom)
assert.Equal(t, "custom", fmt.Sprint(errorCategory))
}
func TestGetErrorCategory(t *testing.T) {
errorCategory = ErrorCompliance
assert.Equal(t, GetErrorCategory(), errorCategory)
}