예제 #1
0
func TestGetInstanceNetcoupe(t *testing.T) {
	e, _ := netcoupe.New(netcoupe.Config{})
	r, err := GetInstance("netcoupe", config.Config{})
	if err != nil {
		t.Errorf("failed to get instance :: %v", err)
		return
	}
	if !reflect.DeepEqual(r, e) {
		t.Errorf("expected %v but got %v", e, r)
	}
}
예제 #2
0
// GetInstance returns a new instance of the requested plugin.
func GetInstance(id string, cfg config.Config) (interface{}, error) {
	switch id {
	case "fusiontables":
		ft, _ := fusiontables.New(cfg.FusionTables)
		return ft, nil
	case "netcoupe":
		nc, _ := netcoupe.New(cfg.Netcoupe)
		return nc, nil
	case "soaringweb":
		sw, _ := soaringweb.New(cfg.SoaringWeb)
		return sw, nil
	case "welt2000":
		wt, _ := welt2000.New(cfg.Welt2000)
		return wt, nil
	default:
		p, ok := registry[id]
		if !ok {
			return nil, fmt.Errorf("unknown plugin id :: %v", id)
		}
		return p, nil
	}
}