Skip to content

Commit

Permalink
api/v1: parallel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Dec 7, 2023
1 parent 2b29515 commit df41f01
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/v1/group_routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func getControlSurface(tb testing.TB, testState *lib.TestRunState) *ControlSurfa
}

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

g0, err := lib.NewGroup("", nil)
assert.NoError(t, err)
g1, err := g0.Group("group 1")
Expand All @@ -71,6 +73,8 @@ func TestGetGroups(t *testing.T) {
cs := getControlSurface(t, getTestRunState(t, lib.Options{}, &minirunner.MiniRunner{Group: g0}))

t.Run("list", func(t *testing.T) {
t.Parallel()

rw := httptest.NewRecorder()
NewHandler(cs).ServeHTTP(rw, httptest.NewRequest(http.MethodGet, "/v1/groups", nil))
res := rw.Result()
Expand All @@ -82,6 +86,8 @@ func TestGetGroups(t *testing.T) {
assert.NotEmpty(t, body)

t.Run("document", func(t *testing.T) {
t.Parallel()

var doc groupsJSONAPI
assert.NoError(t, json.Unmarshal(body, &doc))
if assert.NotEmpty(t, doc.Data) {
Expand All @@ -90,6 +96,8 @@ func TestGetGroups(t *testing.T) {
})

t.Run("groups", func(t *testing.T) {
t.Parallel()

var envelop groupsJSONAPI
require.NoError(t, json.Unmarshal(body, &envelop))
require.Len(t, envelop.Data, 3)
Expand Down Expand Up @@ -121,7 +129,9 @@ func TestGetGroups(t *testing.T) {
})
})
for _, gp := range []*lib.Group{g0, g1, g2} {
gp := gp
t.Run(gp.Name, func(t *testing.T) {
t.Parallel()
rw := httptest.NewRecorder()
NewHandler(cs).ServeHTTP(rw, httptest.NewRequest(http.MethodGet, "/v1/groups/"+gp.ID, nil))
res := rw.Result()
Expand Down

0 comments on commit df41f01

Please sign in to comment.