MCPcopy Create free account
hub / github.com/github/gh-aw / TestSpec_PublicAPI_IsCompatible

Function TestSpec_PublicAPI_IsCompatible

pkg/semverutil/spec_test.go:231–288  ·  view source on GitHub ↗

TestSpec_PublicAPI_IsCompatible validates the documented behavior of IsCompatible as described in the semverutil README.md specification.

(t *testing.T)

Source from the content-addressed store, hash-verified

229// TestSpec_PublicAPI_IsCompatible validates the documented behavior of
230// IsCompatible as described in the semverutil README.md specification.
231func TestSpec_PublicAPI_IsCompatible(t *testing.T) {
232 tests := []struct {
233 name string
234 pinVersion string
235 requestedVersion string
236 expected bool
237 }{
238 {
239 name: "same major version with full pin is compatible",
240 pinVersion: "v5.0.0",
241 requestedVersion: "v5",
242 expected: true,
243 },
244 {
245 name: "same major version with different minor is compatible",
246 pinVersion: "v5.1.0",
247 requestedVersion: "v5.0.0",
248 expected: true,
249 },
250 {
251 name: "different major version is not compatible",
252 pinVersion: "v6.0.0",
253 requestedVersion: "v5",
254 expected: false,
255 },
256 {
257 name: "both invalid versions are not compatible",
258 pinVersion: "not-a-version",
259 requestedVersion: "also-not-a-version",
260 expected: false,
261 },
262 {
263 name: "empty strings are not compatible",
264 pinVersion: "",
265 requestedVersion: "",
266 expected: false,
267 },
268 {
269 name: "invalid pin with valid requested is not compatible",
270 pinVersion: "not-a-version",
271 requestedVersion: "v5.0.0",
272 expected: false,
273 },
274 {
275 name: "valid pin with invalid requested is not compatible",
276 pinVersion: "v5.0.0",
277 requestedVersion: "not-a-version",
278 expected: false,
279 },
280 }
281
282 for _, tt := range tests {
283 t.Run(tt.name, func(t *testing.T) {
284 result := IsCompatible(tt.pinVersion, tt.requestedVersion)
285 assert.Equal(t, tt.expected, result, "IsCompatible(%q, %q) mismatch", tt.pinVersion, tt.requestedVersion)
286 })
287 }
288}

Callers

nothing calls this directly

Calls 2

IsCompatibleFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected