Add test for bad volumes

This commit is contained in:
2022-04-01 08:22:06 +02:00
parent 6ea3a923cc
commit a9b75c48c4

View File

@@ -71,6 +71,14 @@ services:
labels: labels:
katenary.io/same-pod: http3 katenary.io/same-pod: http3
# unmapped volumes
novol:
image: nginx
volumes:
- /tmp/data
labels:
katenary.io/ports: 80
volumes: volumes:
data: data:
driver: local 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")
}
}
}
}
}