From 9b3412b79a314da3374d617743e58ebbf074f2e9 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Mon, 23 Dec 2024 08:32:17 +1100 Subject: [PATCH] test: add polysite cronjob tests (#404) --- internal/lagoon/lagoon_test.go | 76 +++++++++++++++++++ .../test9/polysite-only-lagoon.yml | 28 +++++++ 2 files changed, 104 insertions(+) create mode 100644 internal/lagoon/test-resources/lagoon-yaml/test9/polysite-only-lagoon.yml diff --git a/internal/lagoon/lagoon_test.go b/internal/lagoon/lagoon_test.go index 584b2b17..ffa1e094 100644 --- a/internal/lagoon/lagoon_test.go +++ b/internal/lagoon/lagoon_test.go @@ -441,6 +441,82 @@ func TestUnmarshalLagoonYAML(t *testing.T) { }, }, }, + { + name: "test-polysite with project environment cronjobs", + args: args{ + file: "test-resources/lagoon-yaml/test9/lagoon.yml", + l: &YAML{}, + project: "multiproject2", + }, + want: &YAML{ + DockerComposeYAML: "docker-compose.yml", + Environments: Environments{ + "main": Environment{ + Routes: []map[string][]Route{ + { + "nginx": { + { + Name: "a.example.com", + }, + }, + }, + }, + Cronjobs: []Cronjob{ + { + Name: "notdrush cron", + Command: "notdrush cron", + Service: "cli", + Schedule: "*/15 * * * *", + }, + { + Name: "drush cron", + Command: "drush cron", + Service: "cli", + Schedule: "*/5 * * * *", + }, + { + Name: "some other drush cron", + Command: "drush cron", + Service: "cli", + Schedule: "*/5 * * * *", + }, + }, + }, + }, + }, + }, + { + name: "test-polysite with project environment cronjobs no non-polysite", + args: args{ + file: "test-resources/lagoon-yaml/test9/polysite-only-lagoon.yml", + l: &YAML{}, + project: "multiproject2", + }, + want: &YAML{ + DockerComposeYAML: "docker-compose.yml", + Environments: Environments{ + "main": Environment{ + Routes: []map[string][]Route{ + { + "nginx": { + { + Name: "a.example.com", + }, + }, + }, + }, + Cronjobs: []Cronjob{ + { + Name: "notdrush cron", + Command: "notdrush cron", + Service: "cli", + Schedule: "*/15 * * * *", + }, + }, + }, + }, + }, + }, { name: "test-cronjobs-inpod-only", args: args{ diff --git a/internal/lagoon/test-resources/lagoon-yaml/test9/polysite-only-lagoon.yml b/internal/lagoon/test-resources/lagoon-yaml/test9/polysite-only-lagoon.yml new file mode 100644 index 00000000..06f15237 --- /dev/null +++ b/internal/lagoon/test-resources/lagoon-yaml/test9/polysite-only-lagoon.yml @@ -0,0 +1,28 @@ +--- +docker-compose-yaml: docker-compose.yml + +project: content-example-com + +multiproject1: + environments: + main: + cronjobs: + - name: drush cron + schedule: "*/15 * * * *" + command: 'drush cron' + service: cli + routes: + - nginx: + - a.example.com + +multiproject2: + environments: + main: + cronjobs: + - name: notdrush cron + schedule: "*/15 * * * *" + command: 'notdrush cron' + service: cli + routes: + - nginx: + - a.example.com \ No newline at end of file