Skip to content

Commit

Permalink
fix event query update (#212)
Browse files Browse the repository at this point in the history
* fix event query update

* why am i like this

* wrap
  • Loading branch information
MisterSquishy authored Feb 22, 2024
1 parent f5587c1 commit 7507aba
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1.91.1
1.91.2

5 changes: 3 additions & 2 deletions client/event_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ func (c *Client) UpdateEventQuery(ctx context.Context, projectName string, event
resp Envelope
)

bytes, err := json.Marshal(attributes)
body := WireEventQueryAttributes{Attributes: attributes}
bytes, err := json.Marshal(body)
if err != nil {
return event, err
}
if err := c.CallAPI(ctx, "PUT",
fmt.Sprintf("projects/%v/event_queries/%v", eventQueryID, projectName), bytes, &resp); err != nil {
fmt.Sprintf("projects/%v/event_queries/%v", projectName, eventQueryID), Envelope{Data: bytes}, &resp); err != nil {
return nil, err
}
err = json.Unmarshal(resp.Data, &event)
Expand Down
20 changes: 20 additions & 0 deletions lightstep/resource_event_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ resource "lightstep_event_query" "terraform" {
source = "test-source"
query_string = "logs"
}
`

updatedEventQueryConfig := `
resource "lightstep_event_query" "terraform" {
project_name = "` + testProject + `"
name = "updated name"
type = "test-type"
source = "test-source"
query_string = "logs | filter foo == bar"
}
`
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -36,6 +46,16 @@ resource "lightstep_event_query" "terraform" {
resource.TestCheckResourceAttr("lightstep_event_query.terraform", "query_string", "logs"),
),
},
{
Config: updatedEventQueryConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckEventQueryExists("lightstep_event_query.terraform", &eventQuery),
resource.TestCheckResourceAttr("lightstep_event_query.terraform", "name", "updated name"),
resource.TestCheckResourceAttr("lightstep_event_query.terraform", "type", "test-type"),
resource.TestCheckResourceAttr("lightstep_event_query.terraform", "source", "test-source"),
resource.TestCheckResourceAttr("lightstep_event_query.terraform", "query_string", "logs | filter foo == bar"),
),
},
},
})

Expand Down

0 comments on commit 7507aba

Please sign in to comment.