feat: agent metadata with custom collectors

This commit is contained in:
2023-03-02 13:05:24 +01:00
parent 3310c09320
commit 1ff29ae1fb
40 changed files with 998 additions and 256 deletions

View File

@ -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)
}
}