@@ -5,139 +5,36 @@ package git
5
5
6
6
import (
7
7
"context"
8
- "os"
9
8
"testing"
10
9
11
10
"github.com/stretchr/testify/assert"
12
11
)
13
12
14
- const exampleBlame = `
15
- 4b92a6c2df28054ad766bc262f308db9f6066596 1 1 1
16
- author Unknown
17
- author-mail <joe2010xtmf@163.com>
18
- author-time 1392833071
19
- author-tz -0500
20
- committer Unknown
21
- committer-mail <joe2010xtmf@163.com>
22
- committer-time 1392833071
23
- committer-tz -0500
24
- summary Add code of delete user
25
- previous be0ba9ea88aff8a658d0495d36accf944b74888d gogs.go
26
- filename gogs.go
27
- // Copyright 2014 The Gogs Authors. All rights reserved.
28
- ce21ed6c3490cdfad797319cbb1145e2330a8fef 2 2 1
29
- author Joubert RedRat
30
- author-mail <eu+github@redrat.com.br>
31
- author-time 1482322397
32
- author-tz -0200
33
- committer Lunny Xiao
34
- committer-mail <xiaolunwen@gmail.com>
35
- committer-time 1482322397
36
- committer-tz +0800
37
- summary Remove remaining Gogs reference on locales and cmd (#430)
38
- previous 618407c018cdf668ceedde7454c42fb22ba422d8 main.go
39
- filename main.go
40
- // Copyright 2016 The Gitea Authors. All rights reserved.
41
- 4b92a6c2df28054ad766bc262f308db9f6066596 2 3 2
42
- author Unknown
43
- author-mail <joe2010xtmf@163.com>
44
- author-time 1392833071
45
- author-tz -0500
46
- committer Unknown
47
- committer-mail <joe2010xtmf@163.com>
48
- committer-time 1392833071
49
- committer-tz -0500
50
- summary Add code of delete user
51
- previous be0ba9ea88aff8a658d0495d36accf944b74888d gogs.go
52
- filename gogs.go
53
- // Use of this source code is governed by a MIT-style
54
- 4b92a6c2df28054ad766bc262f308db9f6066596 3 4
55
- author Unknown
56
- author-mail <joe2010xtmf@163.com>
57
- author-time 1392833071
58
- author-tz -0500
59
- committer Unknown
60
- committer-mail <joe2010xtmf@163.com>
61
- committer-time 1392833071
62
- committer-tz -0500
63
- summary Add code of delete user
64
- previous be0ba9ea88aff8a658d0495d36accf944b74888d gogs.go
65
- filename gogs.go
66
- // license that can be found in the LICENSE file.
67
-
68
- e2aa991e10ffd924a828ec149951f2f20eecead2 6 6 2
69
- author Lunny Xiao
70
- author-mail <xiaolunwen@gmail.com>
71
- author-time 1478872595
72
- author-tz +0800
73
- committer Sandro Santilli
74
- committer-mail <strk@kbt.io>
75
- committer-time 1478872595
76
- committer-tz +0100
77
- summary ask for go get from code.gitea.io/gitea and change gogs to gitea on main file (#146)
78
- previous 5fc370e332171b8658caed771b48585576f11737 main.go
79
- filename main.go
80
- // Gitea (git with a cup of tea) is a painless self-hosted Git Service.
81
- e2aa991e10ffd924a828ec149951f2f20eecead2 7 7
82
- package main // import "code.gitea.io/gitea"
83
- `
84
-
85
13
func TestReadingBlameOutput (t * testing.T ) {
86
- tempFile , err := os .CreateTemp ("" , ".txt" )
87
- if err != nil {
88
- panic (err )
89
- }
90
-
91
- defer tempFile .Close ()
92
-
93
- if _ , err = tempFile .WriteString (exampleBlame ); err != nil {
94
- panic (err )
95
- }
96
14
ctx , cancel := context .WithCancel (context .Background ())
97
15
defer cancel ()
98
16
99
- blameReader , err := createBlameReader (ctx , "" , "cat" , tempFile .Name ())
100
- if err != nil {
101
- panic (err )
102
- }
17
+ blameReader , err := CreateBlameReader (ctx , "./tests/repos/repo5_pulls" , "f32b0a9dfd09a60f616f29158f772cedd89942d2" , "README.md" )
18
+ assert .NoError (t , err )
103
19
defer blameReader .Close ()
104
20
105
21
parts := []* BlamePart {
106
22
{
107
- "4b92a6c2df28054ad766bc262f308db9f6066596" ,
108
- []string {
109
- "// Copyright 2014 The Gogs Authors. All rights reserved." ,
110
- },
111
- },
112
- {
113
- "ce21ed6c3490cdfad797319cbb1145e2330a8fef" ,
114
- []string {
115
- "// Copyright 2016 The Gitea Authors. All rights reserved." ,
116
- },
117
- },
118
- {
119
- "4b92a6c2df28054ad766bc262f308db9f6066596" ,
23
+ "72866af952e98d02a73003501836074b286a78f6" ,
120
24
[]string {
121
- "// Use of this source code is governed by a MIT-style" ,
122
- "// license that can be found in the LICENSE file." ,
123
- "" ,
25
+ "# test_repo" ,
26
+ "Test repository for testing migration from github to gitea" ,
124
27
},
125
28
},
126
29
{
127
- "e2aa991e10ffd924a828ec149951f2f20eecead2" ,
128
- []string {
129
- "// Gitea (git with a cup of tea) is a painless self-hosted Git Service." ,
130
- "package main // import \" code.gitea.io/gitea\" " ,
131
- },
30
+ "f32b0a9dfd09a60f616f29158f772cedd89942d2" ,
31
+ []string {},
132
32
},
133
- nil ,
134
33
}
135
34
136
35
for _ , part := range parts {
137
36
actualPart , err := blameReader .NextPart ()
138
- if err != nil {
139
- panic (err )
140
- }
37
+ assert .NoError (t , err )
141
38
assert .Equal (t , part , actualPart )
142
39
}
143
40
}
0 commit comments