@@ -15,11 +15,15 @@ import (
1515
1616// Test constants to avoid code duplication
1717const (
18- testOwnerArg = "owner=testowner"
19- testRepoArg = "repo=testrepo"
20- testTemplateRepo = "bsv-blockchain/go-template"
21- testMainGoFile = "main.go"
22- testImagePngFile = "image.png"
18+ testOwnerArg = "owner=testowner"
19+ testRepoArg = "repo=testrepo"
20+ testTemplateRepo = "bsv-blockchain/go-template"
21+ testMainGoFile = "main.go"
22+ testImagePngFile = "image.png"
23+ testOwnerRepoPath = "testowner/testrepo"
24+ testGoFile = "test.go"
25+ testGoTemplate = "go-template"
26+ testBsvBlockchain = "bsv-blockchain"
2327)
2428
2529func TestValidatePath (t * testing.T ) {
@@ -250,22 +254,22 @@ func TestApplyReplacements(t *testing.T) {
250254 name : "single replacement" ,
251255 content : "package " + testTemplateRepo ,
252256 replacements : []struct { from , to string }{
253- {testTemplateRepo , "testowner/testrepo" },
257+ {testTemplateRepo , testOwnerRepoPath },
254258 },
255- path : "test.go" ,
256- wantContent : "package testowner/testrepo" ,
259+ path : testGoFile ,
260+ wantContent : "package " + testOwnerRepoPath ,
257261 wantModified : true ,
258262 },
259263 {
260264 name : "multiple replacements" ,
261- content : testTemplateRepo + " and go-template by bsv-blockchain" ,
265+ content : testTemplateRepo + " and " + testGoTemplate + " by " + testBsvBlockchain ,
262266 replacements : []struct { from , to string }{
263- {testTemplateRepo , "testowner/testrepo" },
264- {"go-template" , "testrepo" },
265- {"bsv-blockchain" , "testowner" },
267+ {testTemplateRepo , testOwnerRepoPath },
268+ {testGoTemplate , "testrepo" },
269+ {testBsvBlockchain , "testowner" },
266270 },
267- path : "test.go" ,
268- wantContent : "testowner/testrepo and testrepo by testowner" ,
271+ path : testGoFile ,
272+ wantContent : testOwnerRepoPath + " and testrepo by testowner" ,
269273 wantModified : true ,
270274 },
271275 {
@@ -306,9 +310,9 @@ func TestCreateReplacements(t *testing.T) {
306310 replacements := createReplacements (owner , repo )
307311
308312 expected := []struct { from , to string }{
309- {testTemplateRepo , "testowner/testrepo" },
310- {"go-template" , "testrepo" },
311- {"bsv-blockchain" , "testowner" },
313+ {testTemplateRepo , testOwnerRepoPath },
314+ {testGoTemplate , "testrepo" },
315+ {testBsvBlockchain , "testowner" },
312316 }
313317
314318 assert .Equal (t , expected , replacements )
@@ -507,11 +511,11 @@ func BenchmarkIsBinaryFile(b *testing.B) {
507511}
508512
509513func BenchmarkApplyReplacements (b * testing.B ) {
510- content := strings .Repeat (testTemplateRepo + " is a template by bsv-blockchain for go-template projects. " , 100 )
514+ content := strings .Repeat (testTemplateRepo + " is a template by " + testBsvBlockchain + " for " + testGoTemplate + " projects. " , 100 )
511515 replacements := []struct { from , to string }{
512- {testTemplateRepo , "testowner/testrepo" },
513- {"go-template" , "testrepo" },
514- {"bsv-blockchain" , "testowner" },
516+ {testTemplateRepo , testOwnerRepoPath },
517+ {testGoTemplate , "testrepo" },
518+ {testBsvBlockchain , "testowner" },
515519 }
516520
517521 b .ResetTimer ()
0 commit comments