c572fcfe04
Rename the Go module path from code.gitea.io/gitea to git.mokoconsulting.tech/MokoConsulting/MokoGitea across the entire codebase. Scope: - go.mod module declaration - 2,235 Go source files (import paths) - Dockerfile WORKDIR and COPY paths - Swagger API templates - golangci.yml linter config External dependencies (code.gitea.io/gitea-vet, code.gitea.io/sdk/gitea, gitea.com/gitea/act, etc.) are intentionally NOT renamed — they are separate upstream modules. Closes #132 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package gitdiff
|
|
|
|
import (
|
|
"bytes"
|
|
"strconv"
|
|
"testing"
|
|
|
|
"git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/translation"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestBuildBlobExcerptDiffSection(t *testing.T) {
|
|
data := &bytes.Buffer{}
|
|
for i := range 100 {
|
|
data.WriteString("a = " + strconv.Itoa(i+1) + "\n")
|
|
}
|
|
|
|
locale := translation.MockLocale{}
|
|
lineMiddle := 50
|
|
diffSection, err := BuildBlobExcerptDiffSection("a.py", bytes.NewReader(data.Bytes()), BlobExcerptOptions{
|
|
LeftIndex: lineMiddle,
|
|
RightIndex: lineMiddle,
|
|
LeftHunkSize: 10,
|
|
RightHunkSize: 10,
|
|
Direction: "up",
|
|
})
|
|
require.NoError(t, err)
|
|
assert.Len(t, diffSection.highlightedRightLines.value, BlobExcerptChunkSize)
|
|
assert.NotEmpty(t, diffSection.highlightedRightLines.value[lineMiddle-BlobExcerptChunkSize-1])
|
|
assert.NotEmpty(t, diffSection.highlightedRightLines.value[lineMiddle-2]) // 0-based
|
|
|
|
diffInline := diffSection.GetComputedInlineDiffFor(diffSection.Lines[1], locale)
|
|
assert.Equal(t, `<span class="n">a</span> <span class="o">=</span> <span class="mi">30</span>`+"\n", string(diffInline.Content))
|
|
}
|