From a9b75c48c41ff10ef4a7d7f6a796df46bb9dfae0 Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Fri, 1 Apr 2022 08:22:06 +0200 Subject: [PATCH] Add test for bad volumes --- generator/main_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/generator/main_test.go b/generator/main_test.go index 32302dd..7797b4b 100644 --- a/generator/main_test.go +++ b/generator/main_test.go @@ -71,6 +71,14 @@ services: labels: katenary.io/same-pod: http3 + # unmapped volumes + novol: + image: nginx + volumes: + - /tmp/data + labels: + katenary.io/ports: 80 + volumes: data: driver: local @@ -263,3 +271,23 @@ func TestIngress(t *testing.T) { } } } + +// Check unmapped volumes +func TestUnmappedVolumes(t *testing.T) { + tmp, p := setUp(t) + defer os.RemoveAll(tmp) + + for name := range p.Data.Services { + if name == "novol" { + path := filepath.Join(tmp, "templates", name+".deployment.yaml") + fp, _ := os.Open(path) + defer fp.Close() + lines, _ := ioutil.ReadAll(fp) + for _, line := range strings.Split(string(lines), "\n") { + if strings.Contains(line, "novol-data") { + t.Error("novol service should not have a volume") + } + } + } + } +}