mirror of
https://github.com/hanzoai/o11y-foundry.git
synced 2026-10-30 18:26:45 +00:00
### Summary - Introduce a `kind` discriminator for Casting. Existing Casting without a kind field keep working, empty kind defaults to `Installation` - New `api/v1alpha1/installation/` subpackage with the Installation Casting, Spec types and holds its own JSON schema from its Go type: `installation/casting.schema.json` - New Machinery interface in `api/v1alpha1/machinery.go` exposes `Kind()` and `TrackableProperties()` so Dispatcher(Getv1alpha1 and Forge/Cast/Gauge) work across any kind without knowing its concrete type. - A root casting.schema.json lists every per-Kind schema to supports IDEs completion from one schema URL - cmd/foundryctl gen schemas reads a list of types from schemaTargets. Adding a kind means adding one entry. Related: https://github.com/SigNoz/platform-pod/issues/1970
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package v1alpha1
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestMerge(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
testCases := []struct {
|
|
name string
|
|
base TypeMetadata
|
|
override TypeMetadata
|
|
want TypeMetadata
|
|
}{
|
|
{
|
|
name: "override Name wins over base",
|
|
base: TypeMetadata{Name: "base"},
|
|
override: TypeMetadata{Name: "override"},
|
|
want: TypeMetadata{Name: "override"},
|
|
},
|
|
{
|
|
name: "override fills in unset base fields",
|
|
base: TypeMetadata{},
|
|
override: TypeMetadata{Name: "fresh"},
|
|
want: TypeMetadata{Name: "fresh"},
|
|
},
|
|
{
|
|
name: "override Annotations (map with omitempty) does not clobber base when unset",
|
|
base: TypeMetadata{Name: "base", Annotations: map[string]string{"a": "1"}},
|
|
override: TypeMetadata{Name: "base"},
|
|
want: TypeMetadata{Name: "base", Annotations: map[string]string{"a": "1"}},
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
base := tc.base
|
|
override := tc.override
|
|
require.NoError(t, Merge(&base, &override))
|
|
assert.Equal(t, tc.want, base)
|
|
})
|
|
}
|
|
}
|