Skip to content

Commit 8661066

Browse files
committed
libgit2: Enable tests
TestMain() without m.Run() resulted in none of the tests being run. This libgit2 package contains tests for both managed and unmanaged transports, enabling it in TestMain() for everything results in the unmanaged transport tests to not run. Add managed transport initialization call to all the managed transport tests to allow unmanaged transport tests to run. Signed-off-by: Sunny <darkowlzz@protonmail.com>
1 parent 36bbaf0 commit 8661066

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pkg/git/libgit2/managed_test.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ import (
4242

4343
const testRepositoryPath = "../testdata/git/repo"
4444

45-
func TestMain(m *testing.M) {
46-
managed.InitManagedTransport(logr.Discard())
47-
}
48-
4945
// Test_ManagedSSH_KeyTypes assures support for the different
5046
// types of keys for SSH Authentication supported by Flux.
5147
func Test_ManagedSSH_KeyTypes(t *testing.T) {
48+
managed.InitManagedTransport(logr.Discard())
49+
5250
tests := []struct {
5351
name string
5452
keyType ssh.KeyPairType
@@ -176,6 +174,8 @@ func Test_ManagedSSH_KeyTypes(t *testing.T) {
176174
// Test_ManagedSSH_KeyExchangeAlgos assures support for the different
177175
// types of SSH key exchange algorithms supported by Flux.
178176
func Test_ManagedSSH_KeyExchangeAlgos(t *testing.T) {
177+
managed.InitManagedTransport(logr.Discard())
178+
179179
tests := []struct {
180180
name string
181181
ClientKex []string
@@ -297,6 +297,8 @@ func Test_ManagedSSH_KeyExchangeAlgos(t *testing.T) {
297297
// Test_ManagedSSH_HostKeyAlgos assures support for the different
298298
// types of SSH Host Key algorithms supported by Flux.
299299
func Test_ManagedSSH_HostKeyAlgos(t *testing.T) {
300+
managed.InitManagedTransport(logr.Discard())
301+
300302
tests := []struct {
301303
name string
302304
keyType ssh.KeyPairType
@@ -457,6 +459,7 @@ func Test_ManagedSSH_HostKeyAlgos(t *testing.T) {
457459
}
458460

459461
func Test_ManagedHTTPCheckout(t *testing.T) {
462+
managed.InitManagedTransport(logr.Discard())
460463
g := NewWithT(t)
461464

462465
timeout := 5 * time.Second
@@ -496,6 +499,7 @@ func Test_ManagedHTTPCheckout(t *testing.T) {
496499
}
497500

498501
func TestManagedCheckoutBranch_Checkout(t *testing.T) {
502+
managed.InitManagedTransport(logr.Discard())
499503
g := NewWithT(t)
500504

501505
timeout := 5 * time.Second
@@ -551,6 +555,7 @@ func TestManagedCheckoutBranch_Checkout(t *testing.T) {
551555
}
552556

553557
func TestManagedCheckoutTag_Checkout(t *testing.T) {
558+
managed.InitManagedTransport(logr.Discard())
554559
g := NewWithT(t)
555560

556561
timeout := 5 * time.Second

0 commit comments

Comments
 (0)