Expose tagged-source delivery through facade and CLI
This commit is contained in:
46
internal/git/source_test.go
Normal file
46
internal/git/source_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestInspectTaggedSourceSupportsLightweightAndAnnotatedTags(t *testing.T) {
|
||||
fixture := newRemoteFixture(t)
|
||||
gitRun(t, fixture.work, "tag", "v1.2.3")
|
||||
gitRun(t, fixture.work, "checkout", "--detach", "HEAD")
|
||||
lightweight, err := InspectTaggedSource(context.Background(), fixture.work, "v1.2.3")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if lightweight.Head != fixture.commit || lightweight.TagCommit != fixture.commit || lightweight.TagObject != fixture.commit || lightweight.TagObjectType != "commit" || lightweight.Status != "" {
|
||||
t.Fatalf("lightweight source = %#v", lightweight)
|
||||
}
|
||||
gitRun(t, fixture.work, "tag", "-d", "v1.2.3")
|
||||
gitRun(t, fixture.work, "tag", "-a", "v1.2.3", "-m", "Historical release")
|
||||
annotated, err := InspectTaggedSource(context.Background(), fixture.work, "v1.2.3")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if annotated.Head != fixture.commit || annotated.TagCommit != fixture.commit || annotated.TagObject == fixture.commit || annotated.TagObjectType != "tag" || annotated.Status != "" {
|
||||
t.Fatalf("annotated source = %#v", annotated)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInspectTaggedSourceReportsDirtyCheckoutAndReadCommitFile(t *testing.T) {
|
||||
fixture := newRemoteFixture(t)
|
||||
gitRun(t, fixture.work, "tag", "v1.2.3")
|
||||
content, err := ReadCommitFile(context.Background(), fixture.work, fixture.commit, "source.txt")
|
||||
if err != nil || string(content) != "candidate" {
|
||||
t.Fatalf("committed content = %q, error = %v", content, err)
|
||||
}
|
||||
writeRepoFile(t, fixture.work, "untracked.txt", "dirty")
|
||||
source, err := InspectTaggedSource(context.Background(), fixture.work, "v1.2.3")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(source.Status, "untracked.txt") {
|
||||
t.Fatalf("dirty status = %q", source.Status)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user