Skip to content

Commit

Permalink
Add example package and test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bitwizeshift committed Jun 16, 2024
1 parent 1eac3c6 commit 811e209
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/friendly-fhir/go-template

go 1.22.3

require github.com/google/go-cmp v0.6.0
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
5 changes: 5 additions & 0 deletions internal/greeting/greeting.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package greeting

func New() string {
return "Hello, world!"
}
18 changes: 18 additions & 0 deletions internal/greeting/greeting_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package greeting_test

import (
"testing"

"github.com/friendly-fhir/go-template/internal/greeting"
"github.com/google/go-cmp/cmp"
)

func TestNew(t *testing.T) {
want := "Hello, world!"

got := greeting.New()

if !cmp.Equal(got, want) {
t.Errorf("greeting.New() = %q, want %q", got, want)
}
}
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package main

import "fmt"
import (
"fmt"

"github.com/friendly-fhir/go-template/internal/greeting"
)

func main() {
fmt.Println("Hello, World!")
fmt.Println(greeting.New())
}

0 comments on commit 811e209

Please sign in to comment.