Esempio n. 1
0
func TestGetInstanceSoaringWeb(t *testing.T) {
	e, _ := soaringweb.New(soaringweb.Config{})
	r, err := GetInstance("soaringweb", 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)
	}
}
Esempio n. 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
	}
}