You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The template names are part of the init UX: omitting `template` must produce
the useful starter, while users who want a blank object must be able to ask
for `empty` explicitly.
Exercise both paths through `initModule` and assert the rendered source rather
than template-helper internals. In particular, protect the alternate
constructor shape: Python reconstructs object state between the constructor
and later function calls, so overriding `__init__` with only user-facing
inputs makes a rendered module load but fail when a function is invoked.
The check also covers the pinned base image, workspace mount, bare empty class,
and leaked Go-template placeholders.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
assertContains(defaultChanges.layer.file(defaultPath + "/src/init_default/__init__.py").contents, "class InitDefault:", "minimal template did not render the module type")
137
+
assertContains(defaultChanges.layer.file(defaultPath + "/src/init_default/__init__.py").contents, "class InitDefault:", "default template did not render the module type")
138
138
139
139
assertContains(legacyChanges.layer.file(legacyPath + "/src/init_legacy/main.py").contents, "class InitLegacy:", "legacy template did not render the module type")
140
140
141
141
null
142
142
}
143
143
144
+
"""
145
+
The default template should render a working module that reads source from
146
+
the workspace and returns a ready-to-build container. The empty template
147
+
should remain available as a bare object class.
148
+
"""
149
+
pub templateCheck(ws: Workspace!): Void @check {
150
+
let defaultPath = outputRoot + "/template-default"
151
+
let compatibleDefaultPath = outputRoot + "/template-default-empty-value"
152
+
let emptyPath = outputRoot + "/template-empty"
153
+
154
+
let defaultChanges = pythonSdk.initModule(ws, name: "template-default", path: defaultPath)
155
+
let defaultSourcePath = defaultPath + "/src/template_default/__init__.py"
0 commit comments