TestHelperMethods tests the helper methods on semantic types
(t *testing.T)
| 570 | |
| 571 | // TestHelperMethods tests the helper methods on semantic types |
| 572 | func TestHelperMethods(t *testing.T) { |
| 573 | t.Run("Version", func(t *testing.T) { |
| 574 | version := Version("1.0.0") |
| 575 | if version.String() != "1.0.0" { |
| 576 | t.Errorf("Version.String() = %q, want %q", version.String(), "1.0.0") |
| 577 | } |
| 578 | if !version.IsValid() { |
| 579 | t.Error("Version.IsValid() = false, want true for non-empty value") |
| 580 | } |
| 581 | |
| 582 | emptyVersion := Version("") |
| 583 | if emptyVersion.IsValid() { |
| 584 | t.Error("Version.IsValid() = true, want false for empty value") |
| 585 | } |
| 586 | }) |
| 587 | |
| 588 | t.Run("JobName", func(t *testing.T) { |
| 589 | job := JobName("agent") |
| 590 | if job.String() != "agent" { |
| 591 | t.Errorf("JobName.String() = %q, want %q", job.String(), "agent") |
| 592 | } |
| 593 | if !job.IsValid() { |
| 594 | t.Error("JobName.IsValid() = false, want true for non-empty value") |
| 595 | } |
| 596 | |
| 597 | emptyJob := JobName("") |
| 598 | if emptyJob.IsValid() { |
| 599 | t.Error("JobName.IsValid() = true, want false for empty value") |
| 600 | } |
| 601 | }) |
| 602 | |
| 603 | t.Run("StepID", func(t *testing.T) { |
| 604 | step := StepID("check_membership") |
| 605 | if step.String() != "check_membership" { |
| 606 | t.Errorf("StepID.String() = %q, want %q", step.String(), "check_membership") |
| 607 | } |
| 608 | if !step.IsValid() { |
| 609 | t.Error("StepID.IsValid() = false, want true for non-empty value") |
| 610 | } |
| 611 | |
| 612 | emptyStep := StepID("") |
| 613 | if emptyStep.IsValid() { |
| 614 | t.Error("StepID.IsValid() = true, want false for empty value") |
| 615 | } |
| 616 | }) |
| 617 | |
| 618 | t.Run("CommandPrefix", func(t *testing.T) { |
| 619 | prefix := CommandPrefix("gh aw") |
| 620 | if prefix.String() != "gh aw" { |
| 621 | t.Errorf("CommandPrefix.String() = %q, want %q", prefix.String(), "gh aw") |
| 622 | } |
| 623 | if !prefix.IsValid() { |
| 624 | t.Error("CommandPrefix.IsValid() = false, want true for non-empty value") |
| 625 | } |
| 626 | |
| 627 | emptyPrefix := CommandPrefix("") |
| 628 | if emptyPrefix.IsValid() { |
| 629 | t.Error("CommandPrefix.IsValid() = true, want false for empty value") |