Files
virtual-kubelet/trace/opencensus/register_test.go
Brian Goff 8d0b843ae4 Refactor CLI initialization (#562)
This cleans up the CLI code significantly.
Also makes some of this re-usable for providers who want to do so.

This also removes the main.go from the top of the tree of the repro,
instead moving it into cmd/virtual-kubelet.
This allows us to better utilize the package namespace (and e.g. mv the
`vkubelet` package to the top of the tree).
2019-04-19 17:02:39 -07:00

46 lines
994 B
Go

package opencensus
import (
"testing"
"github.com/cpuguy83/strongerrors"
"go.opencensus.io/trace"
)
func TestGetTracingExporter(t *testing.T) {
defer delete(tracingExporters, "mock")
mockExporterFn := func(_ TracingExporterOptions) (trace.Exporter, error) {
return nil, nil
}
_, err := GetTracingExporter("notexist", TracingExporterOptions{})
if !strongerrors.IsNotFound(err) {
t.Fatalf("expected not found error, got: %v", err)
}
RegisterTracingExporter("mock", mockExporterFn)
if _, err := GetTracingExporter("mock", TracingExporterOptions{}); err != nil {
t.Fatal(err)
}
}
func TestAvailableExporters(t *testing.T) {
defer delete(tracingExporters, "mock")
mockExporterFn := func(_ TracingExporterOptions) (trace.Exporter, error) {
return nil, nil
}
RegisterTracingExporter("mock", mockExporterFn)
for _, e := range AvailableTraceExporters() {
if e == "mock" {
return
}
}
t.Fatal("could not find mock exporter in list of registered exporters")
}