Initial commit
This commit is contained in:
commit
2d98ed1b5d
33 changed files with 4644 additions and 0 deletions
49
checker/definition_test.go
Normal file
49
checker/definition_test.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package checker
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdk "git.happydns.org/checker-sdk-go/checker"
|
||||
)
|
||||
|
||||
func TestDefinitionSmoke(t *testing.T) {
|
||||
prov, ok := Provider().(sdk.CheckerDefinitionProvider)
|
||||
if !ok {
|
||||
t.Fatalf("Provider does not implement CheckerDefinitionProvider")
|
||||
}
|
||||
def := prov.Definition()
|
||||
if def == nil {
|
||||
t.Fatalf("nil definition")
|
||||
}
|
||||
if def.ID == "" || def.Name == "" {
|
||||
t.Errorf("missing ID/Name: %+v", def)
|
||||
}
|
||||
if !def.HasHTMLReport || !def.HasMetrics {
|
||||
t.Errorf("expected HasHTMLReport and HasMetrics: %+v", def)
|
||||
}
|
||||
if len(def.Rules) == 0 {
|
||||
t.Errorf("definition exposes no rules")
|
||||
}
|
||||
// Recordtype default option must be present for users.
|
||||
var has bool
|
||||
for _, opt := range def.Options.UserOpts {
|
||||
if opt.Id == "recordTypes" {
|
||||
has = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !has {
|
||||
t.Errorf("missing recordTypes user option")
|
||||
}
|
||||
|
||||
// Service restriction.
|
||||
if len(def.Availability.LimitToServices) == 0 {
|
||||
t.Errorf("expected LimitToServices to be set")
|
||||
}
|
||||
}
|
||||
|
||||
func TestProviderKey(t *testing.T) {
|
||||
if Provider().Key() != ObservationKeyResolverPropagation {
|
||||
t.Errorf("unexpected observation key")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue