+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ linters:
- tparallel
- unconvert
- unparam
- usetesting
- whitespace
settings:
errorlint:
Expand Down Expand Up @@ -126,6 +127,14 @@ linters:
checks:
- "all"
- "-QF1008" # allow embedded field in selector
usetesting:
context-background: true
context-todo: true
os-chdir: true
os-mkdir-temp: true
os-setenv: true
os-create-temp: true
os-temp-dir: true
custom:
sliceofpointers:
type: module
Expand Down
45 changes: 22 additions & 23 deletions github/actions_artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package github

import (
"context"
"errors"
"fmt"
"net/http"
Expand Down Expand Up @@ -36,7 +35,7 @@ func TestActionsService_ListArtifacts(t *testing.T) {
Name: Ptr("TheArtifact"),
ListOptions: ListOptions{Page: 2},
}
ctx := context.Background()
ctx := t.Context()
artifacts, _, err := client.Actions.ListArtifacts(ctx, "o", "r", opts)
if err != nil {
t.Errorf("Actions.ListArtifacts returned error: %v", err)
Expand Down Expand Up @@ -66,7 +65,7 @@ func TestActionsService_ListArtifacts_invalidOwner(t *testing.T) {
t.Parallel()
client, _, _ := setup(t)

ctx := context.Background()
ctx := t.Context()
_, _, err := client.Actions.ListArtifacts(ctx, "%", "r", nil)
testURLParseError(t, err)
}
Expand All @@ -75,7 +74,7 @@ func TestActionsService_ListArtifacts_invalidRepo(t *testing.T) {
t.Parallel()
client, _, _ := setup(t)

ctx := context.Background()
ctx := t.Context()
_, _, err := client.Actions.ListArtifacts(ctx, "o", "%", nil)
testURLParseError(t, err)
}
Expand All @@ -89,7 +88,7 @@ func TestActionsService_ListArtifacts_notFound(t *testing.T) {
w.WriteHeader(http.StatusNotFound)
})

ctx := context.Background()
ctx := t.Context()
artifacts, resp, err := client.Actions.ListArtifacts(ctx, "o", "r", nil)
if err == nil {
t.Error("Expected HTTP 404 response")
Expand Down Expand Up @@ -118,7 +117,7 @@ func TestActionsService_ListWorkflowRunArtifacts(t *testing.T) {
})

opts := &ListOptions{Page: 2}
ctx := context.Background()
ctx := t.Context()
artifacts, _, err := client.Actions.ListWorkflowRunArtifacts(ctx, "o", "r", 1, opts)
if err != nil {
t.Errorf("Actions.ListWorkflowRunArtifacts returned error: %v", err)
Expand Down Expand Up @@ -148,7 +147,7 @@ func TestActionsService_ListWorkflowRunArtifacts_invalidOwner(t *testing.T) {
t.Parallel()
client, _, _ := setup(t)

ctx := context.Background()
ctx := t.Context()
_, _, err := client.Actions.ListWorkflowRunArtifacts(ctx, "%", "r", 1, nil)
testURLParseError(t, err)
}
Expand All @@ -157,7 +156,7 @@ func TestActionsService_ListWorkflowRunArtifacts_invalidRepo(t *testing.T) {
t.Parallel()
client, _, _ := setup(t)

ctx := context.Background()
ctx := t.Context()
_, _, err := client.Actions.ListWorkflowRunArtifacts(ctx, "o", "%", 1, nil)
testURLParseError(t, err)
}
Expand All @@ -171,7 +170,7 @@ func TestActionsService_ListWorkflowRunArtifacts_notFound(t *testing.T) {
w.WriteHeader(http.StatusNotFound)
})

ctx := context.Background()
ctx := t.Context()
artifacts, resp, err := client.Actions.ListWorkflowRunArtifacts(ctx, "o", "r", 1, nil)
if err == nil {
t.Error("Expected HTTP 404 response")
Expand Down Expand Up @@ -199,7 +198,7 @@ func TestActionsService_GetArtifact(t *testing.T) {
}`)
})

ctx := context.Background()
ctx := t.Context()
artifact, _, err := client.Actions.GetArtifact(ctx, "o", "r", 1)
if err != nil {
t.Errorf("Actions.GetArtifact returned error: %v", err)
Expand Down Expand Up @@ -235,7 +234,7 @@ func TestActionsService_GetArtifact_invalidOwner(t *testing.T) {
t.Parallel()
client, _, _ := setup(t)

ctx := context.Background()
ctx := t.Context()
_, _, err := client.Actions.GetArtifact(ctx, "%", "r", 1)
testURLParseError(t, err)
}
Expand All @@ -244,7 +243,7 @@ func TestActionsService_GetArtifact_invalidRepo(t *testing.T) {
t.Parallel()
client, _, _ := setup(t)

ctx := context.Background()
ctx := t.Context()
_, _, err := client.Actions.GetArtifact(ctx, "o", "%", 1)
testURLParseError(t, err)
}
Expand All @@ -258,7 +257,7 @@ func TestActionsService_GetArtifact_notFound(t *testing.T) {
w.WriteHeader(http.StatusNotFound)
})

ctx := context.Background()
ctx := t.Context()
artifact, resp, err := client.Actions.GetArtifact(ctx, "o", "r", 1)
if err == nil {
t.Error("Expected HTTP 404 response")
Expand Down Expand Up @@ -299,7 +298,7 @@ func TestActionsService_DownloadArtifact(t *testing.T) {
http.Redirect(w, r, "https://github.com/artifact", http.StatusFound)
})

ctx := context.Background()
ctx := t.Context()
url, resp, err := client.Actions.DownloadArtifact(ctx, "o", "r", 1, 1)
if err != nil {
t.Errorf("Actions.DownloadArtifact returned error: %v", err)
Expand Down Expand Up @@ -355,7 +354,7 @@ func TestActionsService_DownloadArtifact_invalidOwner(t *testing.T) {
client, _, _ := setup(t)
client.RateLimitRedirectionalEndpoints = tc.respectRateLimits

ctx := context.Background()
ctx := t.Context()
_, _, err := client.Actions.DownloadArtifact(ctx, "%", "r", 1, 1)
testURLParseError(t, err)
})
Expand Down Expand Up @@ -384,7 +383,7 @@ func TestActionsService_DownloadArtifact_invalidRepo(t *testing.T) {
client, _, _ := setup(t)
client.RateLimitRedirectionalEndpoints = tc.respectRateLimits

ctx := context.Background()
ctx := t.Context()
_, _, err := client.Actions.DownloadArtifact(ctx, "o", "%", 1, 1)
testURLParseError(t, err)
})
Expand Down Expand Up @@ -418,7 +417,7 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_dontFollowRedire
http.Redirect(w, r, "https://github.com/artifact", http.StatusMovedPermanently)
})

ctx := context.Background()
ctx := t.Context()
_, resp, _ := client.Actions.DownloadArtifact(ctx, "o", "r", 1, 0)
if resp.StatusCode != http.StatusMovedPermanently {
t.Errorf("Actions.DownloadArtifact return status %d, want %d", resp.StatusCode, http.StatusMovedPermanently)
Expand Down Expand Up @@ -459,7 +458,7 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_followRedirects(
http.Redirect(w, r, "https://github.com/artifact", http.StatusFound)
})

ctx := context.Background()
ctx := t.Context()
url, resp, err := client.Actions.DownloadArtifact(ctx, "o", "r", 1, 1)
if err != nil {
t.Errorf("Actions.DownloadArtifact return error: %v", err)
Expand Down Expand Up @@ -507,7 +506,7 @@ func TestActionsService_DownloadArtifact_unexpectedCode(t *testing.T) {
w.WriteHeader(http.StatusNoContent)
})

ctx := context.Background()
ctx := t.Context()
url, resp, err := client.Actions.DownloadArtifact(ctx, "o", "r", 1, 1)
if err == nil {
t.Fatal("Actions.DownloadArtifact should return error on unexpected code")
Expand All @@ -533,7 +532,7 @@ func TestActionsService_DeleteArtifact(t *testing.T) {
testMethod(t, r, "DELETE")
})

ctx := context.Background()
ctx := t.Context()
_, err := client.Actions.DeleteArtifact(ctx, "o", "r", 1)
if err != nil {
t.Errorf("Actions.DeleteArtifact return error: %v", err)
Expand All @@ -554,7 +553,7 @@ func TestActionsService_DeleteArtifact_invalidOwner(t *testing.T) {
t.Parallel()
client, _, _ := setup(t)

ctx := context.Background()
ctx := t.Context()
_, err := client.Actions.DeleteArtifact(ctx, "%", "r", 1)
testURLParseError(t, err)
}
Expand All @@ -563,7 +562,7 @@ func TestActionsService_DeleteArtifact_invalidRepo(t *testing.T) {
t.Parallel()
client, _, _ := setup(t)

ctx := context.Background()
ctx := t.Context()
_, err := client.Actions.DeleteArtifact(ctx, "o", "%", 1)
testURLParseError(t, err)
}
Expand All @@ -577,7 +576,7 @@ func TestActionsService_DeleteArtifact_notFound(t *testing.T) {
w.WriteHeader(http.StatusNotFound)
})

ctx := context.Background()
ctx := t.Context()
resp, err := client.Actions.DeleteArtifact(ctx, "o", "r", 1)
if err == nil {
t.Error("Expected HTTP 404 response")
Expand Down
Loading
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载