Skip to content

Commit

Permalink
Update existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tara Gu committed Oct 28, 2019
1 parent dee85c3 commit 18933ce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
20 changes: 20 additions & 0 deletions pkg/reconciler/revision/queueing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package revision

import (
"context"
"knative.dev/serving/pkg/apis/config"
"testing"
"time"

Expand Down Expand Up @@ -133,6 +134,24 @@ func getTestDeploymentConfigMap() *corev1.ConfigMap {
}
}

func getTestDefaultsConfig() *config.Defaults {
c, _ := config.NewDefaultsConfigFromConfigMap(getTestDefaultsConfigMap())
// ignoring error as test controller is generated
return c
}

func getTestDefaultsConfigMap() *corev1.ConfigMap {
return &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: config.DefaultsConfigName,
Namespace: system.Namespace(),
},
Data: map[string]string{
"container-concurrency": "1",
},
}
}

func newTestController(t *testing.T) (
context.Context,
context.CancelFunc,
Expand All @@ -148,6 +167,7 @@ func newTestController(t *testing.T) (

configs := []*corev1.ConfigMap{
getTestDeploymentConfigMap(),
getTestDefaultsConfigMap(),
{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace(),
Expand Down
12 changes: 8 additions & 4 deletions pkg/reconciler/revision/revision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ func TestResolutionFailed(t *testing.T) {
// TODO(mattmoor): add coverage of a Reconcile fixing a stale logging URL
func TestUpdateRevWithWithUpdatedLoggingURL(t *testing.T) {
deploymentConfig := getTestDeploymentConfig()
ctx, _, controller, watcher := newTestControllerWithConfig(t, deploymentConfig, &corev1.ConfigMap{
defaultsConfig := getTestDefaultsConfigMap()
ctx, _, controller, watcher := newTestControllerWithConfig(t, deploymentConfig, defaultsConfig, &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace(),
Name: metrics.ConfigMapName(),
Expand Down Expand Up @@ -482,7 +483,8 @@ func TestIstioOutboundIPRangesInjection(t *testing.T) {

func getPodAnnotationsForConfig(t *testing.T, configMapValue string, configAnnotationOverride string) map[string]string {
controllerConfig := getTestDeploymentConfig()
ctx, _, controller, watcher := newTestControllerWithConfig(t, controllerConfig)
defaultsConfig := getTestDefaultsConfigMap()
ctx, _, controller, watcher := newTestControllerWithConfig(t, controllerConfig, defaultsConfig)

// Resolve image references to this "digest"
digest := "foo@sha256:deadbeef"
Expand Down Expand Up @@ -557,7 +559,8 @@ func TestGlobalResyncOnConfigMapUpdateRevision(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
controllerConfig := getTestDeploymentConfig()
ctx, informers, ctrl, watcher := newTestControllerWithConfig(t, controllerConfig)
defaultsConfig := getTestDefaultsConfigMap()
ctx, informers, ctrl, watcher := newTestControllerWithConfig(t, controllerConfig, defaultsConfig)

ctx, cancel := context.WithCancel(ctx)
grp := errgroup.Group{}
Expand Down Expand Up @@ -713,7 +716,8 @@ func TestGlobalResyncOnConfigMapUpdateDeployment(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
controllerConfig := getTestDeploymentConfig()
ctx, informers, ctrl, watcher := newTestControllerWithConfig(t, controllerConfig)
defaultsConfig := getTestDefaultsConfigMap()
ctx, informers, ctrl, watcher := newTestControllerWithConfig(t, controllerConfig, defaultsConfig)

ctx, cancel := context.WithCancel(ctx)
grp := errgroup.Group{}
Expand Down

0 comments on commit 18933ce

Please sign in to comment.