Update database and rp to use default parameters
parent
0a5330327f
commit
688ebe8167
|
@ -34,17 +34,7 @@ func NewClient(host string) (*Client, error) {
|
|||
// include both the database and retention policy. In-flight requests can be
|
||||
// cancelled using the provided context.
|
||||
func (c *Client) Query(ctx context.Context, query mrfusion.Query) (mrfusion.Response, error) {
|
||||
db := ""
|
||||
if len(query.Database) > 0 {
|
||||
db = query.Database
|
||||
}
|
||||
|
||||
rp := ""
|
||||
if len(query.RP) > 0 {
|
||||
rp = query.RP
|
||||
}
|
||||
|
||||
q := ixClient.NewQuery(query.Command, db, rp)
|
||||
q := ixClient.NewQuery(query.Command, query.Database, query.RP)
|
||||
resps := make(chan (response))
|
||||
go func() {
|
||||
resp, err := c.ix.Query(q)
|
||||
|
|
|
@ -38,7 +38,10 @@ func Test_Influx_MakesRequestsToQueryEndpoint(t *testing.T) {
|
|||
t.Fatal("Unexpected error initializing client: err:", err)
|
||||
}
|
||||
|
||||
_, err = series.Query(context.Background(), "show databases")
|
||||
query := mrfusion.Query{
|
||||
Command: "show databases",
|
||||
}
|
||||
_, err = series.Query(context.Background(), query)
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error but was", err)
|
||||
}
|
||||
|
@ -68,7 +71,11 @@ func Test_Influx_CancelsInFlightRequests(t *testing.T) {
|
|||
|
||||
errs := make(chan (error))
|
||||
go func() {
|
||||
_, err := series.Query(ctx, "show databases")
|
||||
query := mrfusion.Query{
|
||||
Command: "show databases",
|
||||
}
|
||||
|
||||
_, err := series.Query(ctx, query)
|
||||
errs <- err
|
||||
}()
|
||||
|
||||
|
|
Loading…
Reference in New Issue