Skip to content

Commit 5ce770c

Browse files
committed
fixup! fixup! modules can declare zero version requirements
1 parent 3310dba commit 5ce770c

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

docs/module-definition.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
This file is the definition of a Zero module. It contains a list of all the required parameters to be able to prompt a user for choices during `zero init`, information about how to template the contents of the module during `zero create`, and the information needed for the module to run (`zero apply`).
33
It also declares the module's dependencies to determine the order of execution in relation to other modules.
44

5-
| Parameters | type | Description |
6-
|---------------|-----------------|--------------------------------------------------|
7-
| `name` | string | Name of module |
8-
| `description` | string | Description of the module |
9-
| `template` | template | default settings for templating out the module |
10-
| `author` | string | Author of the module |
11-
| `icon` | string | Path to logo image |
12-
| `parameters` | list(Parameter) | Parameters to prompt users |
5+
| Parameters | type | Description |
6+
|---------------|------------------|--------------------------------------------------|
7+
| `name` | string | Name of module |
8+
| `description` | string | Description of the module |
9+
| `template` | template | default settings for templating out the module |
10+
| `author` | string | Author of the module |
11+
| `icon` | string | Path to logo image |
12+
| `parameters` | list(Parameter) | Parameters to prompt users |
13+
| `zeroVersion` | string(go-semver)| Zero versions its compatible with |
1314

1415

1516
### Template

internal/module/module_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,24 @@ func TestParseModuleConfig(t *testing.T) {
122122

123123
t.Run("Should validate against valid versions", func(t *testing.T) {
124124
moduleConstraints := mod.ZeroVersion.Constraints.String()
125+
126+
// Mocking zero's version, testing against ">= 3.0.0, <= 4.0.0"
125127
const newZeroVersion = "3.0.5"
126128
originalVersion := version.AppVersion
127129
version.AppVersion = newZeroVersion
128130
defer func() { version.AppVersion = originalVersion }()
129-
// mockVersionAs("2.0.0")
131+
// end of mock
132+
130133
isValid := moduleconfig.ValidateZeroVersion(mod)
131134
assert.Equal(t, true, isValid, fmt.Sprintf("Version should satisfy %s", moduleConstraints))
132135
})
133136

137+
t.Run("default to SNAPSHOT version passes tests", func(t *testing.T) {
138+
assert.Equal(t, "SNAPSHOT", version.AppVersion)
139+
isValid := moduleconfig.ValidateZeroVersion(mod)
140+
assert.Equal(t, true, isValid, "default test run should pass version constraint")
141+
})
142+
134143
}
135144

136145
func findParameter(params []moduleconfig.Parameter, field string) (moduleconfig.Parameter, error) {

0 commit comments

Comments
 (0)