mirror of
https://github.com/ivuorinen/gh-action-readme.git
synced 2026-03-13 08:00:20 +00:00
chore: upgrade Go/deps/workflows to latest and fix gosec regressions (#193)
This commit is contained in:
@@ -162,7 +162,7 @@ func WriteTestFile(t *testing.T, path, content string) {
|
||||
t.Fatalf("failed to create dir %s: %v", dir, err)
|
||||
}
|
||||
|
||||
// #nosec G306 -- test file permissions
|
||||
// #nosec G306 G703 -- test file permissions, path is controlled by test infrastructure
|
||||
if err := os.WriteFile(path, []byte(content), appconstants.FilePermDefault); err != nil {
|
||||
t.Fatalf("failed to write test file %s: %v", path, err)
|
||||
}
|
||||
@@ -396,7 +396,7 @@ func AssertFileNotExists(t *testing.T, path string) {
|
||||
func CreateTestAction(name, description string, inputs map[string]string) string {
|
||||
var inputsYAML bytes.Buffer
|
||||
for key, desc := range inputs {
|
||||
inputsYAML.WriteString(fmt.Sprintf(" %s:\n description: %s\n required: true\n", key, desc))
|
||||
fmt.Fprintf(&inputsYAML, " %s:\n description: %s\n required: true\n", key, desc)
|
||||
}
|
||||
|
||||
result := fmt.Sprintf(appconstants.YAMLFieldName, name)
|
||||
@@ -445,7 +445,7 @@ func SetupTestTemplates(t *testing.T, dir string) {
|
||||
func CreateCompositeAction(name, description string, steps []string) string {
|
||||
var stepsYAML bytes.Buffer
|
||||
for i, step := range steps {
|
||||
stepsYAML.WriteString(fmt.Sprintf(" - name: Step %d\n uses: %s\n", i+1, step))
|
||||
fmt.Fprintf(&stepsYAML, " - name: Step %d\n uses: %s\n", i+1, step)
|
||||
}
|
||||
|
||||
result := fmt.Sprintf(appconstants.YAMLFieldName, name)
|
||||
@@ -521,11 +521,9 @@ func SetEnv(t *testing.T, key, value string) func() {
|
||||
}
|
||||
|
||||
// WithContext creates a context with timeout for testing.
|
||||
func WithContext(timeout time.Duration) context.Context {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
_ = cancel // Avoid lostcancel - we're intentionally creating a context without cleanup for testing
|
||||
|
||||
return ctx
|
||||
// The caller is responsible for calling the returned cancel function.
|
||||
func WithContext(timeout time.Duration) (context.Context, context.CancelFunc) {
|
||||
return context.WithTimeout(context.Background(), timeout)
|
||||
}
|
||||
|
||||
// AssertNoError fails the test if err is not nil.
|
||||
|
||||
@@ -697,7 +697,8 @@ func TestWithContext(t *testing.T) {
|
||||
t.Run("creates context with timeout", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
timeout := 100 * time.Millisecond
|
||||
ctx := WithContext(timeout)
|
||||
ctx, cancel := WithContext(timeout)
|
||||
defer cancel()
|
||||
|
||||
if ctx == nil {
|
||||
t.Fatal("expected context to be created")
|
||||
@@ -719,7 +720,8 @@ func TestWithContext(t *testing.T) {
|
||||
|
||||
t.Run("context eventually times out", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := WithContext(1 * time.Millisecond)
|
||||
ctx, cancel := WithContext(1 * time.Millisecond)
|
||||
defer cancel()
|
||||
|
||||
// Wait a bit longer than the timeout
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
|
||||
Reference in New Issue
Block a user