Beispiel #1
0
func TestGetInstanceWelt2000(t *testing.T) {
	e, _ := welt2000.New(welt2000.Config{})
	r, err := GetInstance("welt2000", 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)
	}
}
Beispiel #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
	}
}