Skip to content

Commit

Permalink
Integration test coverage increase (G-Research#436)
Browse files Browse the repository at this point in the history
Increase aim integration test coverage
  • Loading branch information
fabiovincenzi authored and suprjinx committed Oct 23, 2023
1 parent 2d161ce commit 48233c8
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 18 deletions.
27 changes: 24 additions & 3 deletions tests/integration/golang/aim/app/update_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ func (s *UpdateAppTestSuite) Test_Ok() {
"/apps/%s", app.ID,
),
)
assert.Nil(
s.T(),
s.AIMClient.WithMethod(
http.MethodPut,
).WithRequest(
tt.requestBody,
).WithResponse(
&resp,
).DoRequest(
"/apps/%s", app.ID,
),
)
assert.Equal(s.T(), "app-type", resp.Type)
assert.Equal(s.T(), response.AppState{"app-state-key": "new-app-state-value"}, resp.State)
})
Expand Down Expand Up @@ -116,13 +128,23 @@ func (s *UpdateAppTestSuite) Test_Error() {

tests := []struct {
name string
ID uuid.UUID
requestBody any
error string
}{
{
name: "UpdateAppWithIncorrectState",
ID: app.ID,
requestBody: map[string]any{
"State": "this-cannot-unmarshal",
},
error: "cannot unmarshal",
},
{
name: "UpdateAppWithUnknownID",
ID: uuid.New(),
requestBody: map[string]any{},
error: "Not Found",
},
}
for _, tt := range tests {
Expand All @@ -137,11 +159,10 @@ func (s *UpdateAppTestSuite) Test_Error() {
).WithResponse(
&resp,
).DoRequest(
"/apps/%s", app.ID,
"/apps/%s", tt.ID,
),
)
assert.Nil(s.T(), err)
assert.Contains(s.T(), resp.Message, "cannot unmarshal")
assert.Contains(s.T(), resp.Message, tt.error)
})
}
}
25 changes: 23 additions & 2 deletions tests/integration/golang/aim/dashboard/update_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ func (s *UpdateDashboardTestSuite) Test_Ok() {
"/dashboards/%s", dashboard.ID,
),
)
assert.Nil(
s.T(),
s.AIMClient.WithMethod(
http.MethodPut,
).WithRequest(
tt.requestBody,
).WithResponse(
&resp,
).DoRequest(
"/dashboards/%s", dashboard.ID,
),
)

actualDashboard, err := s.DashboardFixtures.GetDashboardByID(context.Background(), dashboard.ID.String())

Expand Down Expand Up @@ -147,13 +159,22 @@ func (s *UpdateDashboardTestSuite) Test_Error() {

tests := []struct {
name string
ID uuid.UUID
requestBody map[string]interface{}
error string
}{
{
name: "UpdateDashboardWithIncorrectDescriptionType",
ID: dashboard.ID,
requestBody: map[string]interface{}{
"Description": map[string]interface{}{"Description": "latest-description"},
},
error: "cannot unmarshal",
},
{
name: "UpdateDashboardWithUnknownID",
ID: uuid.New(),
error: "Not Found",
},
}
for _, tt := range tests {
Expand All @@ -166,9 +187,9 @@ func (s *UpdateDashboardTestSuite) Test_Error() {
).WithResponse(
&resp,
).DoRequest(
"/dashboards/%s", dashboard.ID,
"/dashboards/%s", tt.ID,
))
assert.Contains(s.T(), resp.Message, "cannot unmarshal")
assert.Contains(s.T(), resp.Message, tt.error)
})
}
}
18 changes: 13 additions & 5 deletions tests/integration/golang/aim/experiment/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,20 @@ func (s *DeleteExperimentTestSuite) Test_Error() {
assert.Nil(s.T(), err)

tests := []struct {
name string
ID string
name string
ID string
error string
}{
{
ID: "123",
name: "DeleteWithUnknownIDFails",
ID: "123",
name: "DeleteWithUnknownIDFails",
error: "Not Found",
},
{
name: "DeleteIncorrectExperimentID",
error: `: unable to parse experiment id "incorrect_experiment_id": strconv.ParseInt:` +
` parsing "incorrect_experiment_id": invalid syntax`,
ID: "incorrect_experiment_id",
},
}
for _, tt := range tests {
Expand All @@ -121,7 +129,7 @@ func (s *DeleteExperimentTestSuite) Test_Error() {
"/experiments/%s", tt.ID,
),
)
assert.Contains(s.T(), resp.Error(), "Not Found")
assert.Contains(s.T(), resp.Error(), tt.error)
assert.NoError(s.T(), err)
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,20 @@ func (s *GetExperimentActivityTestSuite) Test_Error() {
assert.Nil(s.T(), err)

tests := []struct {
name string
ID string
name string
ID string
error string
}{
{
name: "GetInvalidExperimentID",
ID: "123",
name: "GetInvalidExperimentID",
ID: "123",
error: "Not Found",
},
{
name: "DeleteIncorrectExperimentID",
error: `: unable to parse experiment id "incorrect_experiment_id": strconv.ParseInt:` +
` parsing "incorrect_experiment_id": invalid syntax`,
ID: "incorrect_experiment_id",
},
}
for _, tt := range tests {
Expand All @@ -94,9 +102,9 @@ func (s *GetExperimentActivityTestSuite) Test_Error() {
assert.Nil(s.T(), s.AIMClient.WithQuery(map[any]any{
"limit": 4,
}).WithResponse(&resp).DoRequest(
"/experiments/%s/runs", tt.ID,
"/experiments/%s/activity", tt.ID,
))
assert.Contains(s.T(), resp.Error(), "Not Found")
assert.Contains(s.T(), resp.Error(), tt.error)
})
}
}
14 changes: 12 additions & 2 deletions tests/integration/golang/aim/run/update_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,23 @@ func (s *UpdateRunTestSuite) Test_Error() {
}()
tests := []struct {
name string
ID string
requestBody any
error string
}{
{
name: "UpdateRunWithIncorrectArchived",
ID: s.run.ID,
requestBody: map[string]any{
"Archived": "this-cannot-unmarshal",
},
error: "cannot unmarshal",
},
{
name: "UpdateRunWithUnknownID",
ID: "incorrect-ID",
requestBody: map[string]any{},
error: "unable to find run 'incorrect-ID'",
},
}
for _, tt := range tests {
Expand All @@ -119,10 +129,10 @@ func (s *UpdateRunTestSuite) Test_Error() {
).WithResponse(
&resp,
).DoRequest(
"/runs/%s", s.run.ID,
"/runs/%s", tt.ID,
),
)
assert.Contains(s.T(), resp.Message, "cannot unmarshal")
assert.Contains(s.T(), resp.Message, tt.error)
})
}
}

0 comments on commit 48233c8

Please sign in to comment.