// 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 := NewBlock() e := testConfig.LoadBlock(configBlockYaml) assert.Nil(t, e) assert.Equal(t, "foo", testConfig.Name) 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()) } */