2023-01-20 03:41:35 -06:00
|
|
|
package pfs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sort"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/google/go-cmp/cmp"
|
2023-03-15 11:04:28 -05:00
|
|
|
"github.com/grafana/kindsys"
|
2023-01-20 03:41:35 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// This is a brick-dumb test that just ensures known schema interfaces are being
|
|
|
|
// loaded correctly from their declarations in .cue files.
|
|
|
|
//
|
|
|
|
// If this test fails, it's either because:
|
|
|
|
// - They're not being loaded correctly - there's a bug in kindsys or pfs somewhere, fix it
|
|
|
|
// - The set of schema interfaces has been modified - update the static list here
|
|
|
|
func TestSchemaInterfacesAreLoaded(t *testing.T) {
|
|
|
|
knownSI := []string{"PanelCfg", "DataQuery", "DataSourceCfg"}
|
|
|
|
all := kindsys.SchemaInterfaces(nil)
|
|
|
|
var loadedSI []string
|
|
|
|
for k := range all {
|
|
|
|
loadedSI = append(loadedSI, k)
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Strings(knownSI)
|
|
|
|
sort.Strings(loadedSI)
|
|
|
|
|
|
|
|
if diff := cmp.Diff(knownSI, loadedSI); diff != "" {
|
|
|
|
t.Fatalf("kindsys cue-declared schema interfaces differ from ComposableKinds go struct:\n%s", diff)
|
|
|
|
}
|
|
|
|
}
|