mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-06 08:15:48 -04:00
join: make Azure instance names k8s compliant (#807)
join: make Azure instance names k8s compliant
This commit is contained in:
parent
edd51cb137
commit
d1195d1d5f
4 changed files with 133 additions and 23 deletions
63
joinservice/internal/kubernetes/kubernetes_test.go
Normal file
63
joinservice/internal/kubernetes/kubernetes_test.go
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
Copyright (c) Edgeless Systems GmbH
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/goleak"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
goleak.VerifyTestMain(m)
|
||||
}
|
||||
|
||||
func TestK8sCompliantHostname(t *testing.T) {
|
||||
testCases := map[string]struct {
|
||||
input string
|
||||
expected string
|
||||
wantErr bool
|
||||
}{
|
||||
"no change": {
|
||||
input: "test",
|
||||
expected: "test",
|
||||
},
|
||||
"uppercase": {
|
||||
input: "TEST",
|
||||
expected: "test",
|
||||
},
|
||||
"underscore": {
|
||||
input: "test_node",
|
||||
expected: "test-node",
|
||||
},
|
||||
"empty": {
|
||||
input: "",
|
||||
expected: "",
|
||||
wantErr: true,
|
||||
},
|
||||
"error": {
|
||||
input: "test_node_",
|
||||
expected: "",
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range testCases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
actual, err := k8sCompliantHostname(tc.input)
|
||||
if tc.wantErr {
|
||||
assert.Error(err)
|
||||
return
|
||||
}
|
||||
assert.NoError(err)
|
||||
assert.Equal(tc.expected, actual)
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue