2019-04-20 10:47:00 +08:00
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
2022-11-28 02:20:29 +08:00
|
|
|
// SPDX-License-Identifier: MIT
|
2019-04-20 10:47:00 +08:00
|
|
|
|
2019-06-27 02:15:26 +08:00
|
|
|
package git
|
2019-04-20 10:47:00 +08:00
|
|
|
|
|
|
|
import (
|
2020-07-01 21:01:17 +08:00
|
|
|
"context"
|
2019-04-20 10:47:00 +08:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestReadingBlameOutput(t *testing.T) {
|
2020-07-01 21:01:17 +08:00
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2019-04-20 10:47:00 +08:00
|
|
|
|
2023-01-03 16:17:13 +08:00
|
|
|
blameReader, err := CreateBlameReader(ctx, "./tests/repos/repo5_pulls", "f32b0a9dfd09a60f616f29158f772cedd89942d2", "README.md")
|
|
|
|
assert.NoError(t, err)
|
2019-04-20 10:47:00 +08:00
|
|
|
defer blameReader.Close()
|
|
|
|
|
|
|
|
parts := []*BlamePart{
|
|
|
|
{
|
2023-01-03 16:17:13 +08:00
|
|
|
"72866af952e98d02a73003501836074b286a78f6",
|
2019-04-20 10:47:00 +08:00
|
|
|
[]string{
|
2023-01-03 16:17:13 +08:00
|
|
|
"# test_repo",
|
|
|
|
"Test repository for testing migration from github to gitea",
|
2019-04-20 10:47:00 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2023-01-03 16:17:13 +08:00
|
|
|
"f32b0a9dfd09a60f616f29158f772cedd89942d2",
|
2023-02-09 11:51:02 +08:00
|
|
|
[]string{"", "Do not make any changes to this repo it is used for unit testing"},
|
2019-04-20 10:47:00 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, part := range parts {
|
|
|
|
actualPart, err := blameReader.NextPart()
|
2023-01-03 16:17:13 +08:00
|
|
|
assert.NoError(t, err)
|
2019-04-20 10:47:00 +08:00
|
|
|
assert.Equal(t, part, actualPart)
|
|
|
|
}
|
|
|
|
}
|