Skip to content

Commit 70da609

Browse files
backend: cmd: Add unit test for buildHeadlampCFG configuration mapping
Signed-off-by: CygnusMaximillian <dprajjwal11@gmail.com>
1 parent 2796a66 commit 70da609

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

backend/cmd/server_config_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"testing"
21+
22+
"github.com/kubernetes-sigs/headlamp/backend/pkg/config"
23+
"github.com/kubernetes-sigs/headlamp/backend/pkg/kubeconfig"
24+
"github.com/stretchr/testify/assert"
25+
)
26+
27+
func TestBuildHeadlampCFG(t *testing.T) {
28+
conf := &config.Config{
29+
Port: 4444,
30+
InsecureSsl: true,
31+
ProxyURLs: "http://proxy1,http://proxy2",
32+
}
33+
store := kubeconfig.NewContextStore()
34+
35+
headlampCFG := buildHeadlampCFG(conf, store)
36+
37+
assert.Equal(t, uint(4444), headlampCFG.Port)
38+
assert.True(t, headlampCFG.Insecure)
39+
assert.Equal(t, []string{"http://proxy1", "http://proxy2"}, headlampCFG.ProxyURLs)
40+
assert.Equal(t, store, headlampCFG.KubeConfigStore)
41+
}

0 commit comments

Comments
 (0)