Skip to content

Commit

Permalink
Fix broken return statements swallowing errors
Browse files Browse the repository at this point in the history
There was no comment on either case specifying that the `return nil`
was deliberate instead of `return err`, so I'm assuming these were
typos. I added tests to conserve the error-returning behavior.
  • Loading branch information
mark-rushakoff committed Jan 3, 2017
1 parent c783c3d commit 959c445
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The stress tool `influx_stress` will be removed in a subsequent release. We reco

### Bugfixes

- [#7784](https://github.com/influxdata/influxdb/pull/7784): Fix broken error return on meta client's UpdateUser and DropContinuousQuery methods.
- [#7741](https://github.com/influxdata/influxdb/pull/7741): Fix string quoting and significantly improve performance of `influx_inspect export`.
- [#7698](https://github.com/influxdata/influxdb/pull/7698): CLI was caching db/rp for insert into statements.
- [#7659](https://github.com/influxdata/influxdb/issues/7659): Fix CLI import bug when using self-signed SSL certificates.
Expand Down
4 changes: 2 additions & 2 deletions services/meta/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func (c *Client) UpdateUser(name, password string) error {
}

if err := data.UpdateUser(name, string(hash)); err != nil {
return nil
return err
}

delete(c.authCache, name)
Expand Down Expand Up @@ -853,7 +853,7 @@ func (c *Client) DropContinuousQuery(database, name string) error {
data := c.cacheData.Clone()

if err := data.DropContinuousQuery(database, name); err != nil {
return nil
return err
}

if err := c.commit(data); err != nil {
Expand Down
18 changes: 18 additions & 0 deletions services/meta/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,19 @@ func TestMetaClient_CreateUser(t *testing.T) {
}
}

func TestMetaClient_UpdateUser(t *testing.T) {
t.Parallel()

d, c := newClient()
defer os.RemoveAll(d)
defer c.Close()

// UpdateUser that doesn't exist should return an error.
if err := c.UpdateUser("foo", "bar"); err == nil {
t.Fatalf("expected error, got nil")
}
}

func TestMetaClient_ContinuousQueries(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -729,6 +742,11 @@ func TestMetaClient_ContinuousQueries(t *testing.T) {
if err := c.DropContinuousQuery("db0", "cq1"); err != nil {
t.Fatal(err)
}

// Dropping a nonexistent CQ should return an error.
if err := c.DropContinuousQuery("db0", "not-a-cq"); err == nil {
t.Fatal("expected an error, got nil")
}
}

func TestMetaClient_Subscriptions_Create(t *testing.T) {
Expand Down

0 comments on commit 959c445

Please sign in to comment.