MCPcopy Create free account
hub / github.com/docker/cli / TestValidateLink

Function TestValidateLink

opts/opts_test.go:358–383  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

356}
357
358func TestValidateLink(t *testing.T) {
359 valid := []string{
360 "name",
361 "dcdfbe62ecd0:alias",
362 "7a67485460b7642516a4ad82ecefe7f57d0c4916f530561b71a50a3f9c4e33da",
363 "angry_torvalds:linus",
364 }
365 invalid := map[string]string{
366 "": "empty string specified for links",
367 "too:much:of:it": "bad format for links: too:much:of:it",
368 }
369
370 for _, link := range valid {
371 if _, err := ValidateLink(link); err != nil {
372 t.Fatalf("ValidateLink(`%q`) should succeed: error %q", link, err)
373 }
374 }
375
376 for link, expectedError := range invalid {
377 if _, err := ValidateLink(link); err == nil {
378 t.Fatalf("ValidateLink(`%q`) should have failed validation", link)
379 } else if !strings.Contains(err.Error(), expectedError) {
380 t.Fatalf("ValidateLink(`%q`) error should contain %q", link, expectedError)
381 }
382 }
383}
384
385func TestParseLink(t *testing.T) {
386 name, alias, err := ParseLink("name:alias")

Callers

nothing calls this directly

Calls 3

ValidateLinkFunction · 0.85
ContainsMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…