8000 refactor: Do not call teardown manually in tests by gmlewis · Pull Request #3296 · google/go-github · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor: Do not call teardown manually in tests #3296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations 8000
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 21 additions & 42 deletions github/actions_artifacts_test.go
46CA
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
Loading
0