forked from OpsLevel/opslevel-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon_test.go
38 lines (34 loc) · 888 Bytes
/
common_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package opslevel_test
import (
"testing"
ol "github.com/opslevel/opslevel-go/v2023"
"github.com/rocktavious/autopilot/v2023"
)
func TestFormatErrorsWorks(t *testing.T) {
// Arrange
errs := []ol.OpsLevelErrors{
{Message: "can't be blank", Path: []string{"resource", "id"}},
{Message: "is not a valid input", Path: []string{"id"}},
}
// Act
output := ol.FormatErrors(errs)
// Assert
autopilot.Equals(t, `OpsLevel API Errors:
- 'resource.id' can't be blank
- 'id' is not a valid input
`, output.Error())
}
func TestFormatErrorsNoPath(t *testing.T) {
// Arrange
errs := []ol.OpsLevelErrors{
{Message: "can't be blank", Path: []string{"base"}},
{Message: "is not a valid input", Path: []string{""}},
}
// Act
output := ol.FormatErrors(errs)
// Assert
autopilot.Equals(t, `OpsLevel API Errors:
- '' can't be blank
- '' is not a valid input
`, output.Error())
}