Skip to content

Commit bc7a523

Browse files
committed
test coverage
1 parent 15919ae commit bc7a523

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package gitsemver
2+
3+
import "testing"
4+
5+
func Test_GitSemVer_cacheTag_ReplacesExistingTag(t *testing.T) {
6+
vs := &GitSemVer{
7+
tags: []GitTag{
8+
{Tag: "v1.2.3", Commit: "old-commit", Tree: "old-tree"},
9+
{Tag: "v2.0.0", Commit: "other-commit", Tree: "other-tree"},
10+
},
11+
}
12+
13+
vs.cacheTag(GitTag{Tag: "v1.2.3", Commit: "new-commit", Tree: "new-tree"})
14+
15+
if got, want := len(vs.tags), 2; got != want {
16+
t.Fatalf("len(tags) = %d, want %d", got, want)
17+
}
18+
if got, want := vs.tags[0].Commit, "new-commit"; got != want {
19+
t.Fatalf("tags[0].Commit = %q, want %q", got, want)
20+
}
21+
if got, want := vs.tags[0].Tree, "new-tree"; got != want {
22+
t.Fatalf("tags[0].Tree = %q, want %q", got, want)
23+
}
24+
}

0 commit comments

Comments
 (0)