34 lines
888 B
Go
34 lines
888 B
Go
package internal
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/influxdata/flux"
|
|
"github.com/influxdata/flux/memory"
|
|
"github.com/influxdata/flux/runtime"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
type FluxControllerMock struct {
|
|
QueryFn func(ctx context.Context, compiler flux.Compiler) (flux.Query, error)
|
|
}
|
|
|
|
func NewFluxControllerMock() *FluxControllerMock {
|
|
return &FluxControllerMock{
|
|
QueryFn: func(ctx context.Context, compiler flux.Compiler) (query flux.Query, e error) {
|
|
p, err := compiler.Compile(ctx, runtime.Default)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
alloc := &memory.ResourceAllocator{}
|
|
return p.Start(ctx, alloc)
|
|
},
|
|
}
|
|
}
|
|
|
|
func (m *FluxControllerMock) Query(ctx context.Context, compiler flux.Compiler) (flux.Query, error) {
|
|
return m.QueryFn(ctx, compiler)
|
|
}
|
|
|
|
func (m *FluxControllerMock) PrometheusCollectors() []prometheus.Collector { return nil }
|