github.com/helmwave/helmwave@v0.36.4-0.20240509190856-b35563eba4c6/pkg/hooks/config_test.go (about)

     1  package hooks_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/helmwave/helmwave/pkg/hooks"
     7  	"github.com/invopop/jsonschema"
     8  	"github.com/stretchr/testify/suite"
     9  )
    10  
    11  type ConfigTestSuite struct {
    12  	suite.Suite
    13  }
    14  
    15  func TestConfigTestSuite(t *testing.T) {
    16  	t.Parallel()
    17  	suite.Run(t, new(ConfigTestSuite))
    18  }
    19  
    20  func (s *ConfigTestSuite) TestHooksJSONSchema() {
    21  	schema := hooks.Hooks{}.JSONSchema()
    22  
    23  	s.Require().NotNil(schema)
    24  	s.Require().Equal("array", schema.Type)
    25  }
    26  
    27  func (s *ConfigTestSuite) TestHookJSONSchema() {
    28  	reflector := &jsonschema.Reflector{DoNotReference: true}
    29  	schema := reflector.Reflect(hooks.NewHook())
    30  
    31  	s.Require().NotNil(schema)
    32  
    33  	s.NotNil(schema.Properties.GetPair("cmd"))
    34  	s.NotNil(schema.Properties.GetPair("args"))
    35  	s.NotNil(schema.Properties.GetPair("show"))
    36  	s.NotNil(schema.Properties.GetPair("allow_failure"))
    37  }