Documentation ¶
Index ¶
- func Add(entry string) string
- func ConstructSchema(schemaDef TestSchema) (schema string)
- func Cont(name string, contEntries ...string) (contStr string)
- func EmptyLeaf(name string) string
- func FormatAsDiff(entry string) (diffs string)
- func GetConfigSchema(buf ...[]byte) (schema.ModelSet, error)
- func GetConfigSchemaSkipUnknown(buf ...[]byte) (schema.ModelSet, error)
- func GetConfigSchemaWithWarns(buf ...[]byte) (schema.ModelSet, []xutils.Warning, error)
- func GetFullSchema(buf ...[]byte) (schema.ModelSet, error)
- func Leaf(name, value string) string
- func LeafList(name string, leafListEntries ...string) (leafListStr string)
- func LeafListEntry(name string) string
- func List(name string, listEntries ...string) (listStr string)
- func ListEntry(name string, leaves ...string) (listEntryStr string)
- func LogStack(t *testing.T)
- func LogStackFatal(t *testing.T)
- func LogStackInternal(t *testing.T, fatal bool)
- func Prefix(entry, pfx string) string
- func Rem(entry string) string
- func Root(rootEntries ...string) (rootStr string)
- func Tab(entry string) string
- type NameDef
- type TestCase
- type TestSchema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstructSchema ¶
func ConstructSchema(schemaDef TestSchema) (schema string)
func FormatAsDiff ¶
Initially the +/- for changed lines get added right in front of the element being changed. This function pulls them to the front of the line and inserts a leading space on unchanged lines. Completely blank lines (other than leading tabs) do NOT get a leading space.
func LeafListEntry ¶
func LogStackFatal ¶
func LogStackInternal ¶
Types ¶
type TestCase ¶
type TestCase struct { Description string // What we are testing Template string // Template for schema Schema string // Schema snippet under test Schemas []TestSchema // Alternative to schema/template ExpResult bool // true = schema must be accepted ExpErrMsg string // Can't use empty string. Use either ExpErrs []string // ErrMsg or Errs. NodesToValidate []schema.NodeSpec // Nil if no nodes to validate }
Generic Test Case description allowing for cases where expected result may be acceptance or rejection. In the latter case we verify the error generated against the expected error (empty expected message causes test to fail). For tests we expect to pass, we can provide a set of node(s) with associated property/ies to be validated, or we can specify 'nil'.
Schemas can be provided in 2 different ways:
(a) Single schema + associated 'template'. Useful when testing a small
snippet of schema in a single module context where you don't want to keep duplicating YANG across multiple tests. => Use Schema + Template fields
(b) Multiple schemas. Useful for testing multiple modules. Each
TestSchema needs to provide enough YANG to be pasted into a generic template that contains a module, prefix and imports, but nothing else. => Use Schemas
type TestSchema ¶
type TestSchema struct { Name NameDef Imports []NameDef Includes []string BelongsTo NameDef Prefix string SchemaSnippet string }
Used for creating tests with multiple modules without resorting to reading them in from file as this means you can't read the schema and the test together easily.
func NewTestSchema ¶
func NewTestSchema(namespace, prefix string) *TestSchema
func (*TestSchema) AddBelongsTo ¶
func (ts *TestSchema) AddBelongsTo(namespace, prefix string) *TestSchema
func (*TestSchema) AddInclude ¶
func (ts *TestSchema) AddInclude(module string) *TestSchema
func (*TestSchema) AddSchemaSnippet ¶
func (ts *TestSchema) AddSchemaSnippet(snippet string) *TestSchema