mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
Fixes wait for project creation (#2330)
* Fixes wait for project creation * Fixes unit test * Changes hardcoded string to corev1.NamespaceActive * Removed Kcore package, added unit test and comments * Uses helper.WaitForCmdOut to wait and get the desired output for project list
This commit is contained in:
@@ -33,6 +33,12 @@ func Create(client *occlient.Client, projectName string, wait bool) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unable to create new project")
|
||||
}
|
||||
if wait {
|
||||
err = client.WaitForServiceAccountInNamespace(projectName, "default")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unable to wait for service account")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package project
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
@@ -66,12 +67,25 @@ func TestCreate(t *testing.T) {
|
||||
})
|
||||
|
||||
go func() {
|
||||
fkWatch.Add(testingutil.FakeProjectStatus(corev1.NamespacePhase(""), tt.projectName))
|
||||
fkWatch.Add(testingutil.FakeProjectStatus(corev1.NamespacePhase("Active"), tt.projectName))
|
||||
}()
|
||||
fakeClientSet.ProjClientset.PrependWatchReactor("projects", func(action ktesting.Action) (handled bool, ret watch.Interface, err error) {
|
||||
return true, fkWatch, nil
|
||||
})
|
||||
|
||||
fkWatch2 := watch.NewFake()
|
||||
go func() {
|
||||
fkWatch2.Add(&corev1.ServiceAccount{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "default",
|
||||
},
|
||||
})
|
||||
}()
|
||||
|
||||
fakeClientSet.Kubernetes.PrependWatchReactor("serviceaccounts", func(action ktesting.Action) (handled bool, ret watch.Interface, err error) {
|
||||
return true, fkWatch2, nil
|
||||
})
|
||||
|
||||
// The function we are testing
|
||||
err := Create(client, tt.projectName, true)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user