(t *testing.T)
| 136 | } |
| 137 | |
| 138 | func TestValidateLockSchemaCompatibility(t *testing.T) { |
| 139 | tests := []struct { |
| 140 | name string |
| 141 | content string |
| 142 | lockPath string |
| 143 | expectError bool |
| 144 | errorText string |
| 145 | }{ |
| 146 | { |
| 147 | name: "valid v1 schema", |
| 148 | content: `# gh-aw-metadata: {"schema_version":"v1"} |
| 149 | name: test |
| 150 | `, |
| 151 | lockPath: "test.lock.yml", |
| 152 | expectError: false, |
| 153 | }, |
| 154 | { |
| 155 | name: "valid v2 schema", |
| 156 | content: `# gh-aw-metadata: {"schema_version":"v2","frontmatter_hash":"abc","strict":true} |
| 157 | name: test |
| 158 | `, |
| 159 | lockPath: "test-v2.lock.yml", |
| 160 | expectError: false, |
| 161 | }, |
| 162 | { |
| 163 | name: "legacy format is accepted", |
| 164 | content: `# frontmatter-hash: 1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef |
| 165 | name: test |
| 166 | `, |
| 167 | lockPath: "legacy.lock.yml", |
| 168 | expectError: false, |
| 169 | }, |
| 170 | { |
| 171 | name: "valid v3 schema", |
| 172 | content: `# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"abc","strict":true} |
| 173 | name: test |
| 174 | `, |
| 175 | lockPath: "test-v3.lock.yml", |
| 176 | expectError: false, |
| 177 | }, |
| 178 | { |
| 179 | name: "valid v4 schema", |
| 180 | content: `# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"abc","body_hash":"bodyhash"} |
| 181 | name: test |
| 182 | `, |
| 183 | lockPath: "test-v4.lock.yml", |
| 184 | expectError: false, |
| 185 | }, |
| 186 | { |
| 187 | name: "unsupported future version fails", |
| 188 | content: `# gh-aw-metadata: {"schema_version":"v5"} |
| 189 | name: test |
| 190 | `, |
| 191 | lockPath: "future.lock.yml", |
| 192 | expectError: true, |
| 193 | errorText: "unsupported schema version 'v5'", |
| 194 | }, |
| 195 | { |
nothing calls this directly
no test coverage detected