Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-12-05 02:54:46 +01:00
forgejo/modules/git/blame_test.go

41 lines
946 B
Go
Raw Normal View History

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