Skip to content

Commit

Permalink
assert state of managed transport acc for each test
Browse files Browse the repository at this point in the history
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
  • Loading branch information
aryan9600 committed Jun 9, 2022
1 parent 4ce3131 commit e956721
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pkg/git/libgit2/checkout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import (
. "github.com/onsi/gomega"

"github.com/fluxcd/source-controller/pkg/git"

mt "github.com/fluxcd/source-controller/pkg/git/libgit2/managed"
)

func TestCheckoutBranch_unmanaged(t *testing.T) {
Expand Down Expand Up @@ -136,6 +138,11 @@ func checkoutBranch(t *testing.T, managed bool) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)
if !managed {
g.Expect(mt.Enabled()).To(BeFalse())
} else {
g.Expect(mt.Enabled()).To(BeTrue())
}

branch := CheckoutBranch{
Branch: tt.branch,
Expand Down Expand Up @@ -226,6 +233,11 @@ func checkoutTag(t *testing.T, managed bool) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)
if !managed {
g.Expect(mt.Enabled()).To(BeFalse())
} else {
g.Expect(mt.Enabled()).To(BeTrue())
}

server, err := gittestserver.NewTempGitServer()
g.Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -315,6 +327,11 @@ func TestCheckoutCommit_unmanaged(t *testing.T) {
// via CheckoutCommit.
func checkoutCommit(t *testing.T, managed bool) {
g := NewWithT(t)
if !managed {
g.Expect(mt.Enabled()).To(BeFalse())
} else {
g.Expect(mt.Enabled()).To(BeTrue())
}

server, err := gittestserver.NewTempGitServer()
if err != nil {
Expand Down Expand Up @@ -493,6 +510,11 @@ func checkoutSemVer(t *testing.T, managed bool) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)
if !managed {
g.Expect(mt.Enabled()).To(BeFalse())
} else {
g.Expect(mt.Enabled()).To(BeTrue())
}

semVer := CheckoutSemVer{
SemVer: tt.constraint,
Expand Down Expand Up @@ -611,6 +633,8 @@ func mockSignature(time time.Time) *git2go.Signature {

func TestInitializeRepoWithRemote(t *testing.T) {
g := NewWithT(t)

g.Expect(mt.Enabled()).To(BeFalse())
tmp := t.TempDir()
ctx := context.TODO()
testRepoURL := "https://example.com/foo/bar"
Expand Down

0 comments on commit e956721

Please sign in to comment.