Disable "empty repository" Git test
This is required because the test fails with Git >=v2.41.0 due to changes to commands used by the Git test server. Causing the server to return an error when cloning an empty repository, instead of yielding an empty object. Signed-off-by: Hidde Beydals <hidde@hhh.computer>
This commit is contained in:
parent
2f4b200571
commit
60571c08f1
|
@ -219,57 +219,62 @@ func TestGitRepositoryReconciler_Reconcile(t *testing.T) {
|
|||
testSuspendedObjectDeleteWithArtifact(ctx, g, obj)
|
||||
}
|
||||
|
||||
func TestGitRepositoryReconciler_reconcileSource_emptyRepository(t *testing.T) {
|
||||
g := NewWithT(t)
|
||||
|
||||
server, err := gittestserver.NewTempGitServer()
|
||||
g.Expect(err).NotTo(HaveOccurred())
|
||||
defer os.RemoveAll(server.Root())
|
||||
server.AutoCreate()
|
||||
g.Expect(server.StartHTTP()).To(Succeed())
|
||||
defer server.StopHTTP()
|
||||
|
||||
obj := &sourcev1.GitRepository{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
GenerateName: "empty-",
|
||||
Generation: 1,
|
||||
},
|
||||
Spec: sourcev1.GitRepositorySpec{
|
||||
Interval: metav1.Duration{Duration: interval},
|
||||
Timeout: &metav1.Duration{Duration: timeout},
|
||||
URL: server.HTTPAddress() + "/test.git",
|
||||
},
|
||||
}
|
||||
|
||||
clientBuilder := fakeclient.NewClientBuilder().
|
||||
WithScheme(testEnv.GetScheme()).
|
||||
WithStatusSubresource(&sourcev1.GitRepository{})
|
||||
|
||||
r := &GitRepositoryReconciler{
|
||||
Client: clientBuilder.Build(),
|
||||
EventRecorder: record.NewFakeRecorder(32),
|
||||
Storage: testStorage,
|
||||
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
|
||||
}
|
||||
|
||||
g.Expect(r.Client.Create(context.TODO(), obj)).ToNot(HaveOccurred())
|
||||
defer func() {
|
||||
g.Expect(r.Client.Delete(context.TODO(), obj)).ToNot(HaveOccurred())
|
||||
}()
|
||||
|
||||
var commit git.Commit
|
||||
var includes artifactSet
|
||||
sp := patch.NewSerialPatcher(obj, r.Client)
|
||||
|
||||
got, err := r.reconcileSource(context.TODO(), sp, obj, &commit, &includes, t.TempDir())
|
||||
assertConditions := []metav1.Condition{
|
||||
*conditions.TrueCondition(sourcev1.FetchFailedCondition, "EmptyGitRepository", "git repository is empty"),
|
||||
}
|
||||
g.Expect(obj.Status.Conditions).To(conditions.MatchConditions(assertConditions))
|
||||
g.Expect(err).To(HaveOccurred())
|
||||
g.Expect(got).To(Equal(sreconcile.ResultEmpty))
|
||||
g.Expect(commit).ToNot(BeNil())
|
||||
}
|
||||
// TODO(hidde): Re-enable this test.
|
||||
// It is currently disabled because it fails on machines with Git version
|
||||
// >=v2.41.0 due to changes to commands used by the test server. Causing
|
||||
// the test server to return an error when cloning an empty repository,
|
||||
// instead of yielding an empty object.
|
||||
//func TestGitRepositoryReconciler_reconcileSource_emptyRepository(t *testing.T) {
|
||||
// g := NewWithT(t)
|
||||
//
|
||||
// server, err := gittestserver.NewTempGitServer()
|
||||
// g.Expect(err).NotTo(HaveOccurred())
|
||||
// defer os.RemoveAll(server.Root())
|
||||
// server.AutoCreate()
|
||||
// g.Expect(server.StartHTTP()).To(Succeed())
|
||||
// defer server.StopHTTP()
|
||||
//
|
||||
// obj := &sourcev1.GitRepository{
|
||||
// ObjectMeta: metav1.ObjectMeta{
|
||||
// GenerateName: "empty-",
|
||||
// Generation: 1,
|
||||
// },
|
||||
// Spec: sourcev1.GitRepositorySpec{
|
||||
// Interval: metav1.Duration{Duration: interval},
|
||||
// Timeout: &metav1.Duration{Duration: timeout},
|
||||
// URL: server.HTTPAddress() + "/test.git",
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// clientBuilder := fakeclient.NewClientBuilder().
|
||||
// WithScheme(testEnv.GetScheme()).
|
||||
// WithStatusSubresource(&sourcev1.GitRepository{})
|
||||
//
|
||||
// r := &GitRepositoryReconciler{
|
||||
// Client: clientBuilder.Build(),
|
||||
// EventRecorder: record.NewFakeRecorder(32),
|
||||
// Storage: testStorage,
|
||||
// patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
|
||||
// }
|
||||
//
|
||||
// g.Expect(r.Client.Create(context.TODO(), obj)).ToNot(HaveOccurred())
|
||||
// defer func() {
|
||||
// g.Expect(r.Client.Delete(context.TODO(), obj)).ToNot(HaveOccurred())
|
||||
// }()
|
||||
//
|
||||
// var commit git.Commit
|
||||
// var includes artifactSet
|
||||
// sp := patch.NewSerialPatcher(obj, r.Client)
|
||||
//
|
||||
// got, err := r.reconcileSource(context.TODO(), sp, obj, &commit, &includes, t.TempDir())
|
||||
// assertConditions := []metav1.Condition{
|
||||
// *conditions.TrueCondition(sourcev1.FetchFailedCondition, "EmptyGitRepository", "git repository is empty"),
|
||||
// }
|
||||
// g.Expect(obj.Status.Conditions).To(conditions.MatchConditions(assertConditions))
|
||||
// g.Expect(err).To(HaveOccurred())
|
||||
// g.Expect(got).To(Equal(sreconcile.ResultEmpty))
|
||||
// g.Expect(commit).ToNot(BeNil())
|
||||
//}
|
||||
|
||||
func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) {
|
||||
type options struct {
|
||||
|
|
Loading…
Reference in New Issue