@@ -5,139 +5,36 @@ package git
55
66import (
77 "context"
8- "os"
98 "testing"
109
1110 "github.com/stretchr/testify/assert"
1211)
1312
14- const exampleBlame = `
15- 4b92a6c2df28054ad766bc262f308db9f6066596 1 1 1
16- author Unknown
17- 18- author-time 1392833071
19- author-tz -0500
20- committer Unknown
21- committer-mail <[email protected] > 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- 31- author-time 1482322397
32- author-tz -0200
33- committer Lunny Xiao
34- committer-mail <[email protected] > 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- 44- author-time 1392833071
45- author-tz -0500
46- committer Unknown
47- committer-mail <[email protected] > 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- 57- author-time 1392833071
58- author-tz -0500
59- committer Unknown
60- committer-mail <[email protected] > 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- 71- author-time 1478872595
72- author-tz +0800
73- committer Sandro Santilli
74- committer-mail <[email protected] > 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-
8513func 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- }
9614 ctx , cancel := context .WithCancel (context .Background ())
9715 defer cancel ()
9816
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 )
10319 defer blameReader .Close ()
10420
10521 parts := []* BlamePart {
10622 {
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" ,
12024 []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" ,
12427 },
12528 },
12629 {
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 {},
13232 },
133- nil ,
13433 }
13534
13635 for _ , part := range parts {
13736 actualPart , err := blameReader .NextPart ()
138- if err != nil {
139- panic (err )
140- }
37+ assert .NoError (t , err )
14138 assert .Equal (t , part , actualPart )
14239 }
14340}
0 commit comments