Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Commit

Permalink
Add singleton test for data residency to work around the covery probl…
Browse files Browse the repository at this point in the history
…em, rename config-data-residency.yaml to make it consistent with other files
  • Loading branch information
Jimmy Lin committed Sep 16, 2020
1 parent 061dc41 commit f39db1d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestNewDefaultsConfigFromConfigMapEmpty(t *testing.T) {
t.Run(n, func(t *testing.T) {
_, err := NewDefaultsConfigFromConfigMap(tc.config)
if err != nil {
t.Fatalf("Empty value or no key should pass")
t.Errorf("Empty value or no key should pass")
}
})
}
Expand Down
44 changes: 44 additions & 0 deletions pkg/apis/configs/dataresidency/singleton_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright 2020 Google LLC.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package dataresidency

import (
"context"
"testing"

"github.com/google/go-cmp/cmp"
. "knative.dev/pkg/configmap"
. "knative.dev/pkg/configmap/testing"
)

func TestStoreSingletonLoadWithContext(t *testing.T) {
ctx := context.Background()

storeSingleton := &StoreSingleton{}

_, defaultsConfig := ConfigMapsFromTestFile(t, configName, defaulterKey)
cmw := NewStaticWatcher(defaultsConfig)

store := storeSingleton.Store(ctx, cmw)

t.Run("defaults", func(t *testing.T) {
expected, _ := NewDefaultsConfigFromConfigMap(defaultsConfig)
if diff := cmp.Diff(expected, store.Load().DataResidencyDefaults); diff != "" {
t.Fatalf("Unexpected defaults config (-want, +got): %v", diff)
}
})
}

0 comments on commit f39db1d

Please sign in to comment.