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).
This commit is contained in:
45
trace/opencensus/register_test.go
Normal file
45
trace/opencensus/register_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
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")
|
||||
}
|
||||
Reference in New Issue
Block a user