@@ -590,19 +590,29 @@ func TestReleaseInit(t *testing.T) {
590
590
}
591
591
592
592
func TestReleaseTagAndRelease (t * testing.T ) {
593
- t .Parallel ()
594
593
for _ , test := range []struct {
595
- name string
596
- prBody string
597
- push bool
598
- wantErr bool
594
+ name string
595
+ prBody string
596
+ repoPath string
597
+ repoURL string
598
+ push bool
599
+ wantErr bool
599
600
}{
600
601
{
601
602
name : "runs successfully" ,
602
603
prBody : `<details><summary>go-google-cloud-pubsub-v1: v1.0.1</summary>
604
+ ### Features
605
+ - feat: new feature
606
+ </details>` ,
607
+ repoURL : "https://github.com/googleapis/librarian" ,
608
+ },
609
+ {
610
+ name : "runs successfully from cloned repo" ,
611
+ prBody : `<details><summary>go-google-cloud-pubsub-v1: v1.0.1</summary>
603
612
### Features
604
613
- feat: new feature
605
614
</details>` ,
615
+ repoPath : "testdata/e2e/release/init/single_commit" ,
606
616
},
607
617
} {
608
618
t .Run (test .name , func (t * testing.T ) {
@@ -709,12 +719,20 @@ libraries:
709
719
}))
710
720
defer server .Close ()
711
721
722
+ repo := test .repoURL
723
+ if test .repoPath != "" {
724
+ repo = t .TempDir ()
725
+ err := initRepo (t , repo , test .repoPath )
726
+ if err != nil {
727
+ t .Fatalf ("error initializing fake git repo %s" , err )
728
+ }
729
+ }
712
730
cmdArgs := []string {
713
731
"run" ,
714
732
"github.com/googleapis/librarian/cmd/librarian" ,
715
733
"release" ,
716
734
"tag-and-release" ,
717
- "--repo=https://github.com/googleapis/librarian" ,
735
+ fmt . Sprintf ( "--repo=%s" , repo ) ,
718
736
fmt .Sprintf ("--github-api-endpoint=%s/" , server .URL ),
719
737
"--pr=https://github.com/googleapis/librarian/pull/123" ,
720
738
}
@@ -775,6 +793,7 @@ func newMockGitHubServer(t *testing.T, prTitleFragment string) *httptest.Server
775
793
// initRepo initiates a git repo in the given directory, copy
776
794
// files from source directory and create a commit.
777
795
func initRepo (t * testing.T , dir , source string ) error {
796
+ t .Logf ("initializing repo, dir %s, source %s" , dir , source )
778
797
if err := os .CopyFS (dir , os .DirFS (source )); err != nil {
779
798
return err
780
799
}
0 commit comments