Skip to content

Commit 811e209

Browse files
committed
Add example package and test
The test-merging section was failing due to the lack of a test and thus lack of coverage files. This introduces a basic example test project so that this can be demonstrated.
1 parent 1eac3c6 commit 811e209

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
module github.com/friendly-fhir/go-template
22

33
go 1.22.3
4+
5+
require github.com/google/go-cmp v0.6.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
2+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=

internal/greeting/greeting.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package greeting
2+
3+
func New() string {
4+
return "Hello, world!"
5+
}

internal/greeting/greeting_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package greeting_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/friendly-fhir/go-template/internal/greeting"
7+
"github.com/google/go-cmp/cmp"
8+
)
9+
10+
func TestNew(t *testing.T) {
11+
want := "Hello, world!"
12+
13+
got := greeting.New()
14+
15+
if !cmp.Equal(got, want) {
16+
t.Errorf("greeting.New() = %q, want %q", got, want)
17+
}
18+
}

main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package main
22

3-
import "fmt"
3+
import (
4+
"fmt"
5+
6+
"github.com/friendly-fhir/go-template/internal/greeting"
7+
)
48

59
func main() {
6-
fmt.Println("Hello, World!")
10+
fmt.Println(greeting.New())
711
}

0 commit comments

Comments
 (0)