mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-18 08:26:38 +02:00
692b27578c
* Add context option to runtime; Add dynamic namespace to kubectl client * Add namespace runtime arg * Fixes & Debugging * Pass options in k8s runtime * Set namespace on k8s resources * Additional Logging * More debugging * Remove Debugging * Ensure namespace exists * Add debugging * Refactor namespaceExists check * Fix * Fix * Fix * Fix * Change the way we check for namespace * Fix * Tidying Up * Fix Test * Fix merge bugs * Serialize k8s namespaces * Add namespace to watch * Serialize namespace when creating k8s namespace Co-authored-by: Ben Toogood <ben@micro.mu> Co-authored-by: Asim Aslam <asim@aslam.me>
48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
package client
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
)
|
|
|
|
func TestTemplates(t *testing.T) {
|
|
name := "foo"
|
|
version := "123"
|
|
typ := "service"
|
|
namespace := "default"
|
|
|
|
// Render default service
|
|
s := NewService(name, version, typ, namespace)
|
|
bs := new(bytes.Buffer)
|
|
if err := renderTemplate(templates["service"], bs, s); err != nil {
|
|
t.Errorf("Failed to render kubernetes service: %v", err)
|
|
}
|
|
|
|
// Render default deployment
|
|
d := NewDeployment(name, version, typ, namespace)
|
|
bd := new(bytes.Buffer)
|
|
if err := renderTemplate(templates["deployment"], bd, d); err != nil {
|
|
t.Errorf("Failed to render kubernetes deployment: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestFormatName(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
expect string
|
|
}{
|
|
{"foobar", "foobar"},
|
|
{"foo-bar", "foo-bar"},
|
|
{"foo.bar", "foo-bar"},
|
|
{"Foo.Bar", "foo-bar"},
|
|
{"go.micro.foo.bar", "go-micro-foo-bar"},
|
|
}
|
|
|
|
for _, test := range testCases {
|
|
v := Format(test.name)
|
|
if v != test.expect {
|
|
t.Fatalf("Expected name %s for %s got: %s", test.expect, test.name, v)
|
|
}
|
|
}
|
|
}
|