mirror of
https://github.com/rancher/k3k.git
synced 2026-03-06 03:31:17 +00:00
* wip cert webhook * fix lint * cleanup and refactor * fix go.mod * removed logs * renamed * small simplification * improved logging * improved logging * some tests for config data * fix logs * moved interface
45 lines
881 B
Go
45 lines
881 B
Go
package agent
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
func Test_virtualAgentData(t *testing.T) {
|
|
type args struct {
|
|
serviceIP string
|
|
token string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
expectedData map[string]string
|
|
}{
|
|
{
|
|
name: "simple config",
|
|
args: args{
|
|
serviceIP: "10.0.0.21",
|
|
token: "dnjklsdjnksd892389238",
|
|
},
|
|
expectedData: map[string]string{
|
|
"server": "https://10.0.0.21:6443",
|
|
"token": "dnjklsdjnksd892389238",
|
|
"with-node-id": "true",
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
config := virtualAgentData(tt.args.serviceIP, tt.args.token)
|
|
|
|
data := make(map[string]string)
|
|
err := yaml.Unmarshal([]byte(config), data)
|
|
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, tt.expectedData, data)
|
|
})
|
|
}
|
|
}
|