Skip to content

refactor(test): replace custom string helpers with strings.Contains in resume_test.go #598

Description

@lizhengfeng101

Description

internal/session/resume_test.go defines two custom helper functions (contains and containsSubstring) that reimplement strings.Contains from the standard library:

func contains(s, substr string) bool {
	return len(s) >= len(substr) && (s == substr || len(s) > 0 && containsSubstring(s, substr))
}

func containsSubstring(s, sub string) bool {
	for i := 0; i <= len(s)-len(sub); i++ {
		if s[i:i+len(sub)] == sub {
			return true
		}
	}
	return false
}

These should be replaced with a single call to strings.Contains, which is functionally identical and far more readable.

Scope

  • File: internal/session/resume_test.go
  • Functions to remove: contains, containsSubstring
  • Call site: TestSessionFilePath_ValidID

Acceptance Criteria

  • Remove the contains and containsSubstring helper functions
  • Add "strings" to the import block
  • Replace the call site with strings.Contains(path, expectedSuffix)
  • Tests pass (make test)
  • Code check passes (make check)

Context

Discovered during code review of #590. The custom helpers are unnecessary since strings.Contains provides the same functionality. This is a straightforward cleanup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    goPull requests that update go codegood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions