Skip to content

Commit

Permalink
util meta ut
Browse files Browse the repository at this point in the history
Signed-off-by: liheng.zms <[email protected]>
  • Loading branch information
zmberg committed Jan 3, 2024
1 parent f1da1d3 commit f710c02
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
7 changes: 7 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ metadata:
name: system
---
apiVersion: v1
kind: Namespace
metadata:
labels:
control-plane: controller-manager
name: kruise-daemon-config
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: manager
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/meta.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021.
Copyright 2022 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
39 changes: 39 additions & 0 deletions pkg/util/meta_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright 2022 The Kruise Authors.
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 util

import (
"os"
"testing"
)

func TestMetaGetNamespace(t *testing.T) {
if GetKruiseNamespace() != "kruise-system" {
t.Fatalf("expect(kruise-system), but get(%s)", GetKruiseNamespace())
}
_ = os.Setenv("POD_NAMESPACE", "test")
if GetKruiseNamespace() != "test" {
t.Fatalf("expect(test), but get(%s)", GetKruiseNamespace())
}
if GetKruiseDaemonConfigNamespace() != "kruise-daemon-config" {
t.Fatalf("expect(kruise-daemon-config), but get(%s)", GetKruiseDaemonConfigNamespace())
}
_ = os.Setenv("KRUISE_DAEMON_CONFIG_NS", "test")
if GetKruiseDaemonConfigNamespace() != "test" {
t.Fatalf("expect(test), but get(%s)", GetKruiseDaemonConfigNamespace())
}
}

0 comments on commit f710c02

Please sign in to comment.