(t *testing.T)
| 356 | } |
| 357 | |
| 358 | func 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 | |
| 385 | func TestParseLink(t *testing.T) { |
| 386 | name, alias, err := ParseLink("name:alias") |
nothing calls this directly
no test coverage detected
searching dependent graphs…