55 "fmt"
66
77 routev1 "github.com/openshift/api/route/v1"
8- routefake "github.com/openshift/client-go/route/clientset/versioned/fake"
98 v1 "k8s.io/api/core/v1"
109 "k8s.io/apimachinery/pkg/api/errors"
1110 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -498,20 +497,19 @@ var _ = Describe("ObjectYaml", func() {
498497
499498var _ = Describe ("GetRoute" , func () {
500499 var (
501- routeClient * routefake. Clientset
502- namespace string
503- routeName string
500+ fakeClient client. Client
501+ namespace string
502+ routeName string
504503 )
505504
506505 BeforeEach (func () {
507- routeClient = routefake .NewSimpleClientset ()
508506 namespace = "default"
509507 routeName = "test-route"
510508 })
511509
512510 Context ("when the route exists" , func () {
513- BeforeEach ( func () {
514- route := & routev1.Route {
511+ It ( "should return the URL of the route" , func () {
512+ route := routev1.Route {
515513 ObjectMeta : metav1.ObjectMeta {
516514 Name : routeName ,
517515 Namespace : namespace ,
@@ -524,40 +522,41 @@ var _ = Describe("GetRoute", func() {
524522 },
525523 },
526524 }
527- _ , err := routeClient .RouteV1 ().Routes (namespace ).Create (context .Background (), route , metav1.CreateOptions {})
528- Expect (err ).ToNot (HaveOccurred ())
529- })
530525
531- It ("should return the URL of the route" , func () {
532- url , err := getRoute (routeClient , routeName , namespace )
526+ fakeClient = fake .NewClientBuilder ().WithScheme (testEnv .Scheme ).
527+ WithRuntimeObjects (& route ).Build ()
528+
529+ url , err := getRoute (fakeClient , routeName , namespace )
533530 Expect (err ).ToNot (HaveOccurred ())
534531 Expect (url ).To (Equal ("https://example.com" ))
535532 })
536533 })
537534
538535 Context ("when the route does not exist" , func () {
539536 It ("should return an error" , func () {
540- url , err := getRoute (routeClient , routeName , namespace )
537+ fakeClient = fake .NewClientBuilder ().WithScheme (testEnv .Scheme ).
538+ WithRuntimeObjects ().Build ()
539+
540+ url , err := getRoute (fakeClient , routeName , namespace )
541541 Expect (err ).To (HaveOccurred ())
542542 Expect (url ).To (BeEmpty ())
543543 })
544544 })
545545
546546 Context ("when the route has no ingress" , func () {
547- BeforeEach ( func () {
548- route := & routev1.Route {
547+ It ( "should return an error" , func () {
548+ route := routev1.Route {
549549 ObjectMeta : metav1.ObjectMeta {
550550 Name : routeName ,
551551 Namespace : namespace ,
552552 },
553553 Status : routev1.RouteStatus {},
554554 }
555- _ , err := routeClient .RouteV1 ().Routes (namespace ).Create (context .Background (), route , metav1.CreateOptions {})
556- Expect (err ).ToNot (HaveOccurred ())
557- })
558555
559- It ("should return an error" , func () {
560- url , err := getRoute (routeClient , routeName , namespace )
556+ fakeClient = fake .NewClientBuilder ().WithScheme (testEnv .Scheme ).
557+ WithRuntimeObjects (& route ).Build ()
558+
559+ url , err := getRoute (fakeClient , routeName , namespace )
561560 Expect (err ).To (HaveOccurred ())
562561 Expect (url ).To (BeEmpty ())
563562 })
0 commit comments