summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2019-10-19 16:01:23 -0600
committermo khan <mo.khan@gmail.com>2019-10-19 16:01:23 -0600
commit9b791a5cd600701c99d804557d9e2395f6d07595 (patch)
tree59b6ab3cc340881e05fbf25d53c61fd990d30389
parent57d4f8ae76b7ff7c1bd71df678d39b7670b260f5 (diff)
Add a unit test
-rw-r--r--hello.go6
-rw-r--r--hello_test.go12
2 files changed, 17 insertions, 1 deletions
diff --git a/hello.go b/hello.go
index 9111f5d..07f632f 100644
--- a/hello.go
+++ b/hello.go
@@ -2,6 +2,10 @@ package main
import "fmt"
+func Hello() string {
+ return "Hello, world"
+}
+
func main() {
- fmt.Println("Hello, world")
+ fmt.Println(Hello())
}
diff --git a/hello_test.go b/hello_test.go
new file mode 100644
index 0000000..283ada8
--- /dev/null
+++ b/hello_test.go
@@ -0,0 +1,12 @@
+package main
+
+import "testing"
+
+func TestHello(t *testing.T) {
+ got := Hello()
+ want := "Hello, world"
+
+ if got != want {
+ t.Errorf("got %q want %q", got, want)
+ }
+}