package main

import "testing"

func TestHello(t *testing.T) {
	t.Run("saying hello to people", func(t *testing.T) {
		got := Hello("Drew", "")
		expected := "Hello, Drew"
		assertCorrectMessage(t, got, expected)

	})

	t.Run("say 'Hello, world' when an empty string is supplied", func(t *testing.T) {
		got := Hello("", "")
		expected := "Hello, World"
		assertCorrectMessage(t, got, expected)
	})

	t.Run("in Spanish", func(t *testing.T) {
		got := Hello("Elodie", "Spanish")
		expected := "Hola, Elodie"
		assertCorrectMessage(t, got, expected)
	})

	t.Run("in French", func(t *testing.T) {
		got := Hello("Drew", "French")
		expected := "Bonjour, Drew"
		assertCorrectMessage(t, got, expected)
	})
}

func assertCorrectMessage(t testing.TB, got, expected string) {
	// Needed to tell the test suite that this method is a helper.
	// By doing this when it fails the line number reported will be in
	// our function call rather than inside our test helper.
	t.Helper()
	if got != expected {
		t.Errorf("got %q, expected %q", got, expected)
	}
}
