// Copyright 2024 Matthew Rich . All rights reserved. package config import ( "encoding/json" "github.com/stretchr/testify/assert" "testing" ) func TestNewSchema(t *testing.T) { s := NewSchema("document") assert.NotEqual(t, nil, s) } func TestSchemaValidateJSON(t *testing.T) { // ctx := context.Background() s := NewSchema("block") assert.NotNil(t, s) assert.Nil(t, s.ValidateSchema()) configBlockYaml := ` type: "generic" name: "foo" values: bar: quuz ` testConfig := NewGeneric[any]() e := testConfig.LoadYAML(configBlockYaml) assert.Nil(t, e) jsonDoc, jsonErr := json.Marshal(testConfig) assert.Nil(t, jsonErr) schemaErr := s.Validate(string(jsonDoc)) assert.Nil(t, schemaErr) } func TestSchemaValidateSchema(t *testing.T) { s := NewSchema("document") assert.NotNil(t, s) assert.Nil(t, s.ValidateSchema()) }