From 53312f6fa7f1b0b92258c8d43574c85200b328ca Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 9 Mar 2025 21:14:10 -0600 Subject: [PATCH] test(templates): add test for template processing without variables - Implement test case for processing templates with empty variables - Verify correct population of domains, environment variables, and mounts - Ensure template processing works when no custom variables are provided --- .../templates/config.template.test.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/apps/dokploy/__test__/templates/config.template.test.ts b/apps/dokploy/__test__/templates/config.template.test.ts index fa552f40..2dfab7a4 100644 --- a/apps/dokploy/__test__/templates/config.template.test.ts +++ b/apps/dokploy/__test__/templates/config.template.test.ts @@ -338,4 +338,38 @@ describe("processTemplate", () => { expect(mount.content).toMatch(/totp=[A-Za-z0-9+/]{32}/); }); }); + + describe("Should populate envs, domains and mounts in the case we didn't used any variable", () => { + it("should populate envs, domains and mounts in the case we didn't used any variable", () => { + const template: CompleteTemplate = { + metadata: {} as any, + variables: {}, + config: { + domains: [ + { + serviceName: "plausible", + port: 8000, + host: "${randomDomain}", + }, + ], + env: { + BASE_URL: "http://${randomDomain}", + SECRET_KEY_BASE: "${password:32}", + TOTP_VAULT_KEY: "${base64:128}", + }, + mounts: [ + { + filePath: "/config/secrets.txt", + content: "random_domain=${randomDomain}\nsecret=${password:32}", + }, + ], + }, + }; + + const result = processTemplate(template, mockSchema); + expect(result.envs).toHaveLength(3); + expect(result.domains).toHaveLength(1); + expect(result.mounts).toHaveLength(1); + }); + }); });