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

Function TestHelperMethods

pkg/constants/constants_test.go:572–633  ·  view source on GitHub ↗

TestHelperMethods tests the helper methods on semantic types

(t *testing.T)

Source from the content-addressed store, hash-verified

570
571// TestHelperMethods tests the helper methods on semantic types
572func 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")

Callers

nothing calls this directly

Calls 9

VersionTypeAlias · 0.85
JobNameTypeAlias · 0.85
StepIDTypeAlias · 0.85
CommandPrefixTypeAlias · 0.85
RunMethod · 0.45
StringMethod · 0.45
ErrorfMethod · 0.45
IsValidMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected