feat: agent metadata with custom collectors
This commit is contained in:
@ -11,21 +11,21 @@ import (
|
||||
)
|
||||
|
||||
type validatorTestCase struct {
|
||||
Name string
|
||||
Source string
|
||||
ExpectedResult bool
|
||||
Name string
|
||||
Source string
|
||||
ShouldFail bool
|
||||
}
|
||||
|
||||
var validatorTestCases = []validatorTestCase{
|
||||
{
|
||||
Name: "SpecOK",
|
||||
Source: "testdata/spec-ok.json",
|
||||
ExpectedResult: true,
|
||||
Name: "SpecOK",
|
||||
Source: "testdata/spec-ok.json",
|
||||
ShouldFail: false,
|
||||
},
|
||||
{
|
||||
Name: "SpecMissingProp",
|
||||
Source: "testdata/spec-missing-prop.json",
|
||||
ExpectedResult: false,
|
||||
Name: "SpecMissingProp",
|
||||
Source: "testdata/spec-missing-prop.json",
|
||||
ShouldFail: true,
|
||||
},
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ func TestValidator(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range validatorTestCases {
|
||||
func(tc *validatorTestCase) {
|
||||
func(tc validatorTestCase) {
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@ -55,16 +55,16 @@ func TestValidator(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
result, err := validator.Validate(ctx, &spec)
|
||||
err = validator.Validate(ctx, &spec)
|
||||
|
||||
if e, g := tc.ExpectedResult, result; e != g {
|
||||
t.Errorf("result: expected '%v', got '%v'", e, g)
|
||||
}
|
||||
|
||||
if tc.ExpectedResult && err != nil {
|
||||
if !tc.ShouldFail && err != nil {
|
||||
t.Errorf("+%v", errors.WithStack(err))
|
||||
}
|
||||
|
||||
if tc.ShouldFail && err == nil {
|
||||
t.Error("validation should have failed")
|
||||
}
|
||||
})
|
||||
}(&tc)
|
||||
}(tc)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user