github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/generators/ddl/ddl_test.go (about)

     1  // Copyright (c) 2023, R.I. Pienaar and the Choria Project contributors
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package ddl
     6  
     7  import (
     8  	"encoding/json"
     9  	"testing"
    10  
    11  	"github.com/choria-io/go-choria/internal/fs"
    12  	"github.com/choria-io/go-choria/providers/agent/mcorpc/ddl/agent"
    13  	. "github.com/onsi/ginkgo/v2"
    14  	. "github.com/onsi/gomega"
    15  )
    16  
    17  func TestFileContent(t *testing.T) {
    18  	RegisterFailHandler(Fail)
    19  	RunSpecs(t, "Generators/DDL")
    20  }
    21  
    22  var _ = Describe("Agents", func() {
    23  	Describe("ValidateSchemaFromFS", func() {
    24  		It("Should handle any data type", func() {
    25  			ddlBytes, err := fs.FS.ReadFile("ddl/cache/agent/scout.json")
    26  			Expect(err).ToNot(HaveOccurred())
    27  
    28  			var addl agent.DDL
    29  			err = json.Unmarshal(ddlBytes, &addl)
    30  			Expect(err).ToNot(HaveOccurred())
    31  
    32  			g := &Generator{}
    33  			err = g.ValidateJSON(&addl)
    34  			Expect(err).ToNot(HaveOccurred())
    35  		})
    36  	})
    37  })