mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
d8444d51f2
* 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
20 lines
386 B
Go
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)
|
|
}
|