Skip to content

Commit

Permalink
refactor: Do not call teardown manually in tests (google#3296)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmlewis authored Oct 1, 2024
1 parent 0024ad2 commit e56d378
Show file tree
Hide file tree
Showing 150 changed files with 1,614 additions and 2,928 deletions.
63 changes: 21 additions & 42 deletions github/actions_artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import (
)

func TestActionsService_ListArtifacts(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
client, mux, _ := setup(t)

mux.HandleFunc("/repos/o/r/actions/artifacts", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
Expand Down Expand Up @@ -59,26 +58,23 @@ func TestActionsService_ListArtifacts(t *testing.T) {
}

func TestActionsService_ListArtifacts_invalidOwner(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
client, _, _ := setup(t)

ctx := context.Background()
_, _, err := client.Actions.ListArtifacts(ctx, "%", "r", nil)
testURLParseError(t, err)
}

func TestActionsService_ListArtifacts_invalidRepo(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
client, _, _ := setup(t)

ctx := context.Background()
_, _, err := client.Actions.ListArtifacts(ctx, "o", "%", nil)
testURLParseError(t, err)
}

func TestActionsService_ListArtifacts_notFound(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
client, mux, _ := setup(t)

mux.HandleFunc("/repos/o/r/actions/artifacts", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
Expand All @@ -99,8 +95,7 @@ func TestActionsService_ListArtifacts_notFound(t *testing.T) {
}

func TestActionsService_ListWorkflowRunArtifacts(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
client, mux, _ := setup(t)

mux.HandleFunc("/repos/o/r/actions/runs/1/artifacts", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
Expand Down Expand Up @@ -141,26 +136,23 @@ func TestActionsService_ListWorkflowRunArtifacts(t *testing.T) {
}

func TestActionsService_ListWorkflowRunArtifacts_invalidOwner(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
client, _, _ := setup(t)

ctx := context.Background()
_, _, err := client.Actions.ListWorkflowRunArtifacts(ctx, "%", "r", 1, nil)
testURLParseError(t, err)
}

func TestActionsService_ListWorkflowRunArtifacts_invalidRepo(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
client, _, _ := setup(t)

ctx := context.Background()
_, _, err := client.Actions.ListWorkflowRunArtifacts(ctx, "o", "%", 1, nil)
testURLParseError(t, err)
}

func TestActionsService_ListWorkflowRunArtifacts_notFound(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
client, mux, _ := setup(t)

mux.HandleFunc("/repos/o/r/actions/runs/1/artifacts", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
Expand All @@ -181,8 +173,7 @@ func TestActionsService_ListWorkflowRunArtifacts_notFound(t *testing.T) {
}

func TestActionsService_GetArtifact(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
client, mux, _ := setup(t)

mux.HandleFunc("/repos/o/r/actions/artifacts/1", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
Expand Down Expand Up @@ -228,26 +219,23 @@ func TestActionsService_GetArtifact(t *testing.T) {
}

func TestActionsService_GetArtifact_invalidOwner(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
client, _, _ := setup(t)

ctx := context.Background()
_, _, err := client.Actions.GetArtifact(ctx, "%", "r", 1)
testURLParseError(t, err)
}

func TestActionsService_GetArtifact_invalidRepo(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
client, _, _ := setup(t)

ctx := context.Background()
_, _, err := client.Actions.GetArtifact(ctx, "o", "%", 1)
testURLParseError(t, err)
}

func TestActionsService_GetArtifact_notFound(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
client, mux, _ := setup(t)

mux.HandleFunc("/repos/o/r/actions/artifacts/1", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
Expand All @@ -268,8 +256,7 @@ func TestActionsService_GetArtifact_notFound(t *testing.T) {
}

func TestActionsService_DownloadArtifact(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
client, mux, _ := setup(t)

mux.HandleFunc("/repos/o/r/actions/artifacts/1/zip", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
Expand Down Expand Up @@ -307,26 +294,23 @@ func TestActionsService_DownloadArtifact(t *testing.T) {
}

func TestActionsService_DownloadArtifact_invalidOwner(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
client, _, _ := setup(t)

ctx := context.Background()
_, _, err := client.Actions.DownloadArtifact(ctx, "%", "r", 1, 1)
testURLParseError(t, err)
}

func TestActionsService_DownloadArtifact_invalidRepo(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
client, _, _ := setup(t)

ctx := context.Background()
_, _, err := client.Actions.DownloadArtifact(ctx, "o", "%", 1, 1)
testURLParseError(t, err)
}

func TestActionsService_DownloadArtifact_StatusMovedPermanently_dontFollowRedirects(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
client, mux, _ := setup(t)

mux.HandleFunc("/repos/o/r/actions/artifacts/1/zip", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
Expand All @@ -341,8 +325,7 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_dontFollowRedire
}

func TestActionsService_DownloadArtifact_StatusMovedPermanently_followRedirects(t *testing.T) {
client, mux, serverURL, teardown := setup()
defer teardown()
client, mux, serverURL := setup(t)

mux.HandleFunc("/repos/o/r/actions/artifacts/1/zip", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
Expand All @@ -369,8 +352,7 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_followRedirects(
}

func TestActionsService_DeleteArtifact(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
client, mux, _ := setup(t)

mux.HandleFunc("/repos/o/r/actions/artifacts/1", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
Expand All @@ -394,26 +376,23 @@ func TestActionsService_DeleteArtifact(t *testing.T) {
}

func TestActionsService_DeleteArtifact_invalidOwner(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
client, _, _ := setup(t)

ctx := context.Background()
_, err := client.Actions.DeleteArtifact(ctx, "%", "r", 1)
testURLParseError(t, err)
}

func TestActionsService_DeleteArtifact_invalidRepo(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
client, _, _ := setup(t)

ctx := context.Background()
_, err := client.Actions.DeleteArtifact(ctx, "o", "%", 1)
testURLParseError(t, err)
}

func TestActionsService_DeleteArtifact_notFound(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
client, mux, _ := setup(t)

mux.HandleFunc("/repos/o/r/actions/artifacts/1", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
Expand Down
Loading

0 comments on commit e56d378

Please sign in to comment.