diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 77956b1..08b257a 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -1,11 +1,19 @@ name: Test CI/CD Pipeline -on: push +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] jobs: tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: '1.25.4' - name: Run tests - run: echo "Running tests..." + run: go test -v ./... diff --git a/mathops.go b/mathops.go index d372526..d9d42fc 100644 --- a/mathops.go +++ b/mathops.go @@ -14,3 +14,7 @@ func Multiply(a, b int) int { func IsEven(n int) bool { return n%2 == 0 } + +func displayName(name string) string { + return "Hello, " + name + "!" +} diff --git a/mathops_test.go b/mathops_test.go index 40191d7..a27c705 100644 --- a/mathops_test.go +++ b/mathops_test.go @@ -66,3 +66,23 @@ func TestIsEven(t *testing.T) { }) } } + +func TestDisplayName(t *testing.T) { + tests := []struct { + name string + input string + want string + }{ + {name: "regular name", input: "Alice", want: "Hello, Alices!"}, + {name: "empty name", input: "", want: "Hello, !"}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := displayName(tt.input) + if got != tt.want { + t.Fatalf("displayName(%q) = %q, want %q", tt.input, got, tt.want) + } + }) + } +}